home *** CD-ROM | disk | FTP | other *** search
MacBinary | 1992-07-19 | 383.9 KB | [ONLN/HLX2] |
open in:
MacOS 8.1
|
Win98
|
DOS
browse contents |
view JSON data
|
view as text
This file was processed as: MacBinary
(archive/macBinary).
Confidence | Program | Detection | Match Type | Support
|
---|
10%
| dexvert
| MacBinary (archive/macBinary)
| fallback
| Supported |
100%
| file
| MacBinary II, inited, Sat Jul 18 20:06:38 1992, modified Sat Jul 18 20:06:57 1992, creator 'HLX2', type 'ONLN', 385182 bytes "Multibuffering Sounds" , at 0x5e11e 7566 bytes resource
| default (weak)
| |
99%
| file
| data
| default
| |
100%
| TrID
| MacBinary 2
| default (weak)
| |
100%
| siegfried
| fmt/1762 MacBinary (II)
| default
| |
100%
| lsar
| MacBinary
| default
|
|
id metadata |
---|
key | value |
---|
macFileType | [ONLN] |
macFileCreator | [HLX2] |
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 15 4d 75 6c 74 69 62 | 75 66 66 65 72 69 6e 67 |..Multib|uffering|
|00000010| 20 53 6f 75 6e 64 73 00 | 00 00 00 00 00 00 00 00 | Sounds.|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 4f 4e 4c 4e 48 4c 58 | 32 01 00 00 00 00 00 00 |.ONLNHLX|2.......|
|00000050| 00 00 00 00 05 e0 9e 00 | 00 1d 8e a6 8e 62 8e a6 |........|.....b..|
|00000060| 8e 62 a1 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |.b......|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 2b 4b 00 00 |........|....+K..|
|00000080| 41 52 4f 55 4e 44 20 41 | 4e 44 20 41 52 4f 55 4e |AROUND A|ND AROUN|
|00000090| 44 3a 20 4d 55 4c 54 49 | 2d 42 55 46 46 45 52 49 |D: MULTI|-BUFFERI|
|000000a0| 4e 47 20 53 4f 55 4e 44 | 53 0d 4e 45 49 4c 20 44 |NG SOUND|S.NEIL D|
|000000b0| 41 59 0d 54 68 65 20 6d | 61 69 6e 20 70 72 6f 62 |AY.The m|ain prob|
|000000c0| 6c 65 6d 20 77 69 74 68 | 20 64 69 67 69 74 61 6c |lem with| digital|
|000000d0| 20 61 75 64 69 6f 20 69 | 73 20 74 68 61 74 20 74 | audio i|s that t|
|000000e0| 68 65 20 64 61 74 61 20 | 6f 66 74 65 6e 20 65 78 |he data |often ex|
|000000f0| 63 65 65 64 73 20 74 68 | 65 20 61 6d 6f 75 6e 74 |ceeds th|e amount|
|00000100| 20 6f 66 20 61 76 61 69 | 6c 61 62 6c 65 20 6d 65 | of avai|lable me|
|00000110| 6d 6f 72 79 2c 20 66 6f | 72 63 69 6e 67 20 70 72 |mory, fo|rcing pr|
|00000120| 6f 67 72 61 6d 6d 65 72 | 73 20 74 6f 20 72 65 73 |ogrammer|s to res|
|00000130| 6f 72 74 20 74 6f 20 6d | 75 6c 74 69 70 6c 65 2d |ort to m|ultiple-|
|00000140| 62 75 66 66 65 72 69 6e | 67 20 73 63 68 65 6d 65 |bufferin|g scheme|
|00000150| 73 2e 20 54 68 69 73 20 | 61 72 74 69 63 6c 65 20 |s. This |article |
|00000160| 70 72 65 73 65 6e 74 73 | 20 6f 6e 65 20 73 75 63 |presents| one suc|
|00000170| 68 20 74 65 63 68 6e 69 | 71 75 65 2c 20 69 6e 20 |h techni|que, in |
|00000180| 74 68 65 20 66 6f 72 6d | 20 6f 66 20 61 20 70 72 |the form| of a pr|
|00000190| 6f 67 72 61 6d 20 63 61 | 6c 6c 65 64 20 4d 75 6c |ogram ca|lled Mul|
|000001a0| 74 69 42 75 66 66 65 72 | 2c 20 61 6e 64 20 65 78 |tiBuffer|, and ex|
|000001b0| 70 6c 6f 72 65 73 20 73 | 6f 6d 65 20 69 6e 74 65 |plores s|ome inte|
|000001c0| 72 65 73 74 69 6e 67 20 | 74 68 69 6e 67 73 20 79 |resting |things y|
|000001d0| 6f 75 20 63 61 6e 20 64 | 6f 20 61 6c 6f 6e 67 20 |ou can d|o along |
|000001e0| 74 68 65 20 77 61 79 2e | 0d 57 68 65 6e 20 64 65 |the way.|.When de|
|000001f0| 61 6c 69 6e 67 20 77 69 | 74 68 20 64 69 67 69 74 |aling wi|th digit|
|00000200| 61 6c 20 61 75 64 69 6f | 2c 20 79 6f 75 d5 72 65 |al audio|, you.re|
|00000210| 20 66 72 65 71 75 65 6e | 74 6c 79 20 67 6f 69 6e | frequen|tly goin|
|00000220| 67 20 74 6f 20 66 69 6e | 64 20 79 6f 75 72 73 65 |g to fin|d yourse|
|00000230| 6c 66 20 69 6e 20 73 69 | 74 75 61 74 69 6f 6e 73 |lf in si|tuations|
|00000240| 20 77 68 65 72 65 20 74 | 68 65 20 73 61 6d 70 6c | where t|he sampl|
|00000250| 65 20 79 6f 75 20 77 61 | 6e 74 20 74 6f 20 70 6c |e you wa|nt to pl|
|00000260| 61 79 20 77 6f 6e d5 74 | 20 66 69 74 20 69 6e 20 |ay won.t| fit in |
|00000270| 74 68 65 20 6d 65 6d 6f | 72 79 20 79 6f 75 20 68 |the memo|ry you h|
|00000280| 61 76 65 20 61 76 61 69 | 6c 61 62 6c 65 2e 20 54 |ave avai|lable. T|
|00000290| 68 69 73 20 6c 65 61 76 | 65 73 20 79 6f 75 20 77 |his leav|es you w|
|000002a0| 69 74 68 20 73 65 76 65 | 72 61 6c 20 61 6c 74 65 |ith seve|ral alte|
|000002b0| 72 6e 61 74 69 76 65 73 | 3a 20 79 6f 75 20 63 61 |rnatives|: you ca|
|000002c0| 6e 20 70 6c 61 79 20 73 | 68 6f 72 74 65 72 20 73 |n play s|horter s|
|000002d0| 6f 75 6e 64 73 3b 20 79 | 6f 75 20 63 61 6e 20 74 |ounds; y|ou can t|
|000002e0| 72 79 20 74 6f 20 73 71 | 75 65 65 7a 65 20 74 68 |ry to sq|ueeze th|
|000002f0| 65 20 73 6f 75 6e 64 20 | 64 6f 77 6e 20 74 6f 20 |e sound |down to |
|00000300| 61 20 6d 6f 72 65 20 6d | 61 6e 61 67 65 61 62 6c |a more m|anageabl|
|00000310| 65 20 73 69 7a 65 20 62 | 79 20 72 65 73 61 6d 70 |e size b|y resamp|
|00000320| 6c 69 6e 67 20 69 74 20 | 61 74 20 61 20 6c 6f 77 |ling it |at a low|
|00000330| 65 72 20 66 72 65 71 75 | 65 6e 63 79 20 6f 72 20 |er frequ|ency or |
|00000340| 62 79 20 63 6f 6d 70 72 | 65 73 73 69 6e 67 20 69 |by compr|essing i|
|00000350| 74 20 28 62 6f 74 68 20 | 6f 66 20 77 68 69 63 68 |t (both |of which|
|00000360| 20 77 69 6c 6c 20 64 65 | 67 72 61 64 65 20 74 68 | will de|grade th|
|00000370| 65 20 66 69 64 65 6c 69 | 74 79 20 6f 66 20 74 68 |e fideli|ty of th|
|00000380| 65 20 73 6f 75 6e 64 29 | 3b 20 6f 72 20 79 6f 75 |e sound)|; or you|
|00000390| 20 63 61 6e 20 74 72 79 | 20 74 6f 20 66 6f 6f 6c | can try| to fool|
|000003a0| 20 74 68 65 20 6d 61 63 | 68 69 6e 65 20 69 6e 74 | the mac|hine int|
|000003b0| 6f 20 74 68 69 6e 6b 69 | 6e 67 20 69 74 20 68 61 |o thinki|ng it ha|
|000003c0| 73 20 74 68 65 20 77 68 | 6f 6c 65 20 73 61 6d 70 |s the wh|ole samp|
|000003d0| 6c 65 20 61 74 20 69 74 | 73 20 64 69 73 70 6f 73 |le at it|s dispos|
|000003e0| 61 6c 2e 20 49 6e 20 63 | 61 73 65 73 20 77 68 65 |al. In c|ases whe|
|000003f0| 72 65 20 79 6f 75 20 64 | 6f 6e d5 74 20 77 61 6e |re you d|on.t wan|
|00000400| 74 20 74 6f 20 63 6f 6d | 70 72 6f 6d 69 73 65 20 |t to com|promise |
|00000410| 6c 65 6e 67 74 68 20 6f | 72 20 71 75 61 6c 69 74 |length o|r qualit|
|00000420| 79 2c 20 74 72 69 63 6b | 65 72 79 20 69 73 20 79 |y, trick|ery is y|
|00000430| 6f 75 72 20 6f 6e 6c 79 | 20 6f 70 74 69 6f 6e 2e |our only| option.|
|00000440| 0d 49 66 20 79 6f 75 d5 | 76 65 20 73 70 65 6e 74 |.If you.|ve spent|
|00000450| 20 61 6e 79 20 74 69 6d | 65 20 77 69 74 68 20 74 | any tim|e with t|
|00000460| 68 65 20 53 6f 75 6e 64 | 20 4d 61 6e 61 67 65 72 |he Sound| Manager|
|00000470| 2c 20 79 6f 75 20 6e 6f | 20 64 6f 75 62 74 20 68 |, you no| doubt h|
|00000480| 61 76 65 20 72 75 6e 20 | 61 63 72 6f 73 73 20 74 |ave run |across t|
|00000490| 68 65 20 72 6f 75 74 69 | 6e 65 20 53 6e 64 50 6c |he routi|ne SndPl|
|000004a0| 61 79 44 6f 75 62 6c 65 | 42 75 66 66 65 72 2c 20 |ayDouble|Buffer, |
|000004b0| 77 68 69 63 68 20 70 72 | 6f 76 69 64 65 73 20 6f |which pr|ovides o|
|000004c0| 6e 65 20 72 65 61 73 6f | 6e 61 62 6c 79 20 73 74 |ne reaso|nably st|
|000004d0| 72 61 69 67 68 74 66 6f | 72 77 61 72 64 20 6d 65 |raightfo|rward me|
|000004e0| 74 68 6f 64 20 6f 66 20 | 69 6d 70 6c 65 6d 65 6e |thod of |implemen|
|000004f0| 74 69 6e 67 20 61 20 64 | 6f 75 62 6c 65 2d 62 75 |ting a d|ouble-bu|
|00000500| 66 66 65 72 69 6e 67 20 | 73 63 68 65 6d 65 2e 20 |ffering |scheme. |
|00000510| 54 68 65 20 61 64 76 61 | 6e 74 61 67 65 20 6f 66 |The adva|ntage of|
|00000520| 20 75 73 69 6e 67 20 53 | 6e 64 50 6c 61 79 44 6f | using S|ndPlayDo|
|00000530| 75 62 6c 65 42 75 66 66 | 65 72 20 69 73 20 74 68 |ubleBuff|er is th|
|00000540| 61 74 20 69 74 20 61 6c | 6c 6f 77 73 20 79 6f 75 |at it al|lows you|
|00000550| 20 74 6f 20 67 65 74 20 | 61 20 66 61 69 72 6c 79 | to get |a fairly|
|00000560| 20 63 75 73 74 6f 6d 69 | 7a 65 64 20 64 6f 75 62 | customi|zed doub|
|00000570| 6c 65 2d 62 75 66 66 65 | 72 69 6e 67 20 73 6f 6c |le-buffe|ring sol|
|00000580| 75 74 69 6f 6e 20 75 70 | 20 61 6e 64 20 72 75 6e |ution up| and run|
|00000590| 6e 69 6e 67 20 77 69 74 | 68 20 76 65 72 79 20 6c |ning wit|h very l|
|000005a0| 69 74 74 6c 65 20 77 6f | 72 6b 2e 20 59 6f 75 20 |ittle wo|rk. You |
|000005b0| 6e 65 65 64 20 6f 6e 6c | 79 20 77 72 69 74 65 20 |need onl|y write |
|000005c0| 61 20 70 72 69 6d 69 6e | 67 20 72 6f 75 74 69 6e |a primin|g routin|
|000005d0| 65 20 66 6f 72 20 73 65 | 74 74 69 6e 67 20 75 70 |e for se|tting up|
|000005e0| 20 74 68 65 20 62 75 66 | 66 65 72 73 20 61 6e 64 | the buf|fers and|
|000005f0| 20 66 69 6c 6c 69 6e 67 | 20 74 68 65 6d 20 69 6e | filling| them in|
|00000600| 69 74 69 61 6c 6c 79 2c | 20 61 20 44 6f 75 62 6c |itially,| a Doubl|
|00000610| 65 42 61 63 6b 20 70 72 | 6f 63 65 64 75 72 65 20 |eBack pr|ocedure |
|00000620| 74 68 61 74 20 74 61 6b | 65 73 20 63 61 72 65 20 |that tak|es care |
|00000630| 6f 66 20 73 77 61 70 70 | 69 6e 67 20 62 75 66 66 |of swapp|ing buff|
|00000640| 65 72 73 20 61 6e 64 20 | 73 65 74 74 69 6e 67 20 |ers and |setting |
|00000650| 66 6c 61 67 73 2c 20 61 | 6e 64 20 61 20 72 65 61 |flags, a|nd a rea|
|00000660| 64 20 73 65 72 76 69 63 | 65 20 72 6f 75 74 69 6e |d servic|e routin|
|00000670| 65 20 66 6f 72 20 66 69 | 6c 6c 69 6e 67 20 65 78 |e for fi|lling ex|
|00000680| 68 61 75 73 74 65 64 20 | 62 75 66 66 65 72 73 3b |hausted |buffers;|
|00000690| 20 74 68 65 20 53 6f 75 | 6e 64 20 4d 61 6e 61 67 | the Sou|nd Manag|
|000006a0| 65 72 20 68 61 6e 64 6c | 65 73 20 61 6c 6c 20 74 |er handl|es all t|
|000006b0| 68 65 20 6f 74 68 65 72 | 20 64 65 74 61 69 6c 73 |he other| details|
|000006c0| 2e 20 53 6e 64 50 6c 61 | 79 44 6f 75 62 6c 65 42 |. SndPla|yDoubleB|
|000006d0| 75 66 66 65 72 20 69 73 | 20 69 6e 20 66 61 63 74 |uffer is| in fact|
|000006e0| 20 75 73 65 64 20 62 79 | 20 74 68 65 20 53 6f 75 | used by| the Sou|
|000006f0| 6e 64 20 4d 61 6e 61 67 | 65 72 d5 73 20 6f 77 6e |nd Manag|er.s own|
|00000700| 20 70 6c 61 79 2d 66 72 | 6f 6d 2d 64 69 73 6b 20 | play-fr|om-disk |
|00000710| 72 6f 75 74 69 6e 65 2c | 20 53 6e 64 53 74 61 72 |routine,| SndStar|
|00000720| 74 46 69 6c 65 50 6c 61 | 79 2e 0d 49 66 20 79 6f |tFilePla|y..If yo|
|00000730| 75 72 20 70 72 6f 67 72 | 61 6d 20 77 69 6c 6c 20 |ur progr|am will |
|00000740| 73 69 6d 70 6c 79 20 70 | 6c 61 79 20 66 72 6f 6d |simply p|lay from|
|00000750| 20 64 69 73 6b 2c 20 79 | 6f 75 72 20 62 65 73 74 | disk, y|our best|
|00000760| 20 62 65 74 20 69 73 20 | 70 72 6f 62 61 62 6c 79 | bet is |probably|
|00000770| 20 65 69 74 68 65 72 20 | 53 6e 64 50 6c 61 79 44 | either |SndPlayD|
|00000780| 6f 75 62 6c 65 42 75 66 | 66 65 72 20 6f 72 20 53 |oubleBuf|fer or S|
|00000790| 6e 64 53 74 61 72 74 46 | 69 6c 65 50 6c 61 79 2e |ndStartF|ilePlay.|
|000007a0| 20 42 6f 74 68 20 6f 66 | 66 65 72 20 67 6f 6f 64 | Both of|fer good|
|000007b0| 20 70 65 72 66 6f 72 6d | 61 6e 63 65 20 70 61 69 | perform|ance pai|
|000007c0| 6e 6c 65 73 73 6c 79 2c | 20 73 61 76 69 6e 67 20 |nlessly,| saving |
|000007d0| 79 6f 75 20 64 65 76 65 | 6c 6f 70 6d 65 6e 74 20 |you deve|lopment |
|000007e0| 74 69 6d 65 20 61 6e 64 | 20 61 76 6f 69 64 69 6e |time and| avoidin|
|000007f0| 67 20 74 68 65 20 6e 65 | 65 64 20 74 6f 20 75 6e |g the ne|ed to un|
|00000800| 64 65 72 73 74 61 6e 64 | 20 74 68 65 20 53 6f 75 |derstand| the Sou|
|00000810| 6e 64 20 4d 61 6e 61 67 | 65 72 20 74 6f 20 61 6e |nd Manag|er to an|
|00000820| 79 20 67 72 65 61 74 20 | 64 65 67 72 65 65 2e 20 |y great |degree. |
|00000830| 49 66 2c 20 68 6f 77 65 | 76 65 72 2c 20 79 6f 75 |If, howe|ver, you|
|00000840| 20 77 61 6e 74 20 74 6f | 20 64 6f 20 73 6f 6d 65 | want to| do some|
|00000850| 20 73 6e 61 7a 7a 69 65 | 72 20 74 68 69 6e 67 73 | snazzie|r things|
|00000860| 20 77 69 74 68 20 79 6f | 75 72 20 73 6f 75 6e 64 | with yo|ur sound|
|00000870| 20 73 75 70 70 6f 72 74 | 2c 20 73 75 63 68 20 61 | support|, such a|
|00000880| 73 20 61 64 64 69 6e 67 | 20 65 66 66 65 63 74 73 |s adding| effects|
|00000890| 20 70 72 6f 63 65 73 73 | 69 6e 67 2c 20 61 20 64 | process|ing, a d|
|000008a0| 65 65 70 65 72 20 75 6e | 64 65 72 73 74 61 6e 64 |eeper un|derstand|
|000008b0| 69 6e 67 20 6f 66 20 6d | 75 6c 74 69 70 6c 65 20 |ing of m|ultiple |
|000008c0| 62 75 66 66 65 72 69 6e | 67 20 69 73 20 65 73 73 |bufferin|g is ess|
|000008d0| 65 6e 74 69 61 6c 2e 20 | 52 65 61 64 20 6f 6e 20 |ential. |Read on |
|000008e0| 2e 20 2e 20 2e 0d 0d 50 | 52 4f 43 45 53 53 49 4e |. . ...P|ROCESSIN|
|000008f0| 47 20 53 4f 55 4e 44 53 | 20 57 49 54 48 20 54 48 |G SOUNDS| WITH TH|
|00000900| 45 20 41 53 43 0d 41 75 | 64 69 6f 20 73 75 70 70 |E ASC.Au|dio supp|
|00000910| 6f 72 74 20 6f 6e 20 74 | 68 65 20 4d 61 63 69 6e |ort on t|he Macin|
|00000920| 74 6f 73 68 20 63 6f 6d | 70 75 74 65 72 20 69 73 |tosh com|puter is|
|00000930| 20 68 61 6e 64 6c 65 64 | 20 62 79 20 74 68 65 20 | handled| by the |
|00000940| 41 70 70 6c 65 20 53 6f | 75 6e 64 20 43 68 69 70 |Apple So|und Chip|
|00000950| 20 28 41 53 43 29 2c 20 | 77 68 69 63 68 20 74 61 | (ASC), |which ta|
|00000960| 6b 65 73 20 63 61 72 65 | 20 6f 66 20 63 6f 6e 76 |kes care| of conv|
|00000970| 65 72 74 69 6e 67 20 74 | 68 65 20 64 69 67 69 74 |erting t|he digit|
|00000980| 61 6c 20 72 65 70 72 65 | 73 65 6e 74 61 74 69 6f |al repre|sentatio|
|00000990| 6e 20 6f 66 20 79 6f 75 | 72 20 73 6f 75 6e 64 20 |n of you|r sound |
|000009a0| 62 61 63 6b 20 74 6f 20 | 61 6e 61 6c 6f 67 2c 20 |back to |analog, |
|000009b0| 77 68 69 63 68 20 63 61 | 6e 20 74 68 65 6e 20 62 |which ca|n then b|
|000009c0| 65 20 70 6c 61 79 65 64 | 20 62 79 20 61 20 73 70 |e played| by a sp|
|000009d0| 65 61 6b 65 72 20 61 74 | 74 61 63 68 65 64 20 74 |eaker at|tached t|
|000009e0| 6f 20 79 6f 75 72 20 4d | 61 63 69 6e 74 6f 73 68 |o your M|acintosh|
|000009f0| 2e 20 28 53 65 65 20 d2 | 53 6f 75 6e 64 3a 20 46 |. (See .|Sound: F|
|00000a00| 72 6f 6d 20 50 68 79 73 | 69 63 61 6c 20 74 6f 20 |rom Phys|ical to |
|00000a10| 44 69 67 69 74 61 6c 20 | 61 6e 64 20 42 61 63 6b |Digital |and Back|
|00000a20| d3 20 66 6f 72 20 61 20 | 64 65 73 63 72 69 70 74 |. for a |descript|
|00000a30| 69 6f 6e 20 6f 66 20 74 | 68 69 73 20 70 72 6f 63 |ion of t|his proc|
|00000a40| 65 73 73 2e 29 0d 59 6f | 75 20 63 61 6e 20 74 68 |ess.).Yo|u can th|
|00000a50| 69 6e 6b 20 6f 66 20 74 | 68 65 20 41 53 43 20 61 |ink of t|he ASC a|
|00000a60| 73 20 61 20 64 69 67 69 | 74 61 6c 2d 74 6f 2d 61 |s a digi|tal-to-a|
|00000a70| 6e 61 6c 6f 67 20 63 6f | 6e 76 65 72 74 65 72 20 |nalog co|nverter |
|00000a80| 77 69 74 68 20 74 77 6f | 20 31 4b 20 62 75 66 66 |with two| 1K buff|
|00000a90| 65 72 73 20 74 6f 20 68 | 6f 6c 64 20 74 68 65 20 |ers to h|old the |
|00000aa0| 64 61 74 61 20 74 6f 20 | 62 65 20 70 72 6f 63 65 |data to |be proce|
|00000ab0| 73 73 65 64 2e 20 57 68 | 65 6e 20 65 69 74 68 65 |ssed. Wh|en eithe|
|00000ac0| 72 20 6f 66 20 74 68 65 | 20 62 75 66 66 65 72 73 |r of the| buffers|
|00000ad0| 20 72 65 61 63 68 65 73 | 20 74 68 65 20 68 61 6c | reaches| the hal|
|00000ae0| 66 2d 66 75 6c 6c 20 6d | 61 72 6b 2c 20 74 68 65 |f-full m|ark, the|
|00000af0| 20 41 53 43 20 67 65 6e | 65 72 61 74 65 73 20 61 | ASC gen|erates a|
|00000b00| 6e 20 69 6e 74 65 72 72 | 75 70 74 20 74 6f 20 6c |n interr|upt to l|
|00000b10| 65 74 20 74 68 65 20 53 | 6f 75 6e 64 20 4d 61 6e |et the S|ound Man|
|00000b20| 61 67 65 72 20 6b 6e 6f | 77 20 74 68 61 74 20 69 |ager kno|w that i|
|00000b30| 74 d5 73 20 61 62 6f 75 | 74 20 74 6f 20 72 75 6e |t.s abou|t to run|
|00000b40| 20 6f 75 74 20 6f 66 20 | 64 61 74 61 2e 20 42 65 | out of |data. Be|
|00000b50| 63 61 75 73 65 20 6f 66 | 20 74 68 69 73 2c 20 69 |cause of| this, i|
|00000b60| 74 d5 73 20 69 6d 70 6f | 72 74 61 6e 74 20 74 6f |t.s impo|rtant to|
|00000b70| 20 6d 61 6b 65 20 73 75 | 72 65 20 74 68 61 74 20 | make su|re that |
|00000b80| 79 6f 75 72 20 62 75 66 | 66 65 72 73 20 61 72 65 |your buf|fers are|
|00000b90| 20 61 20 6d 75 6c 74 69 | 70 6c 65 20 6f 66 20 35 | a multi|ple of 5|
|00000ba0| 31 32 20 62 79 74 65 73 | 2c 20 73 69 6e 63 65 20 |12 bytes|, since |
|00000bb0| 69 6e 20 61 6e 20 61 74 | 74 65 6d 70 74 20 74 6f |in an at|tempt to|
|00000bc0| 20 6b 65 65 70 20 74 68 | 65 20 41 53 43 20 68 61 | keep th|e ASC ha|
|00000bd0| 70 70 79 20 74 68 65 20 | 53 6f 75 6e 64 20 4d 61 |ppy the |Sound Ma|
|00000be0| 6e 61 67 65 72 20 77 69 | 6c 6c 20 70 61 64 20 79 |nager wi|ll pad y|
|00000bf0| 6f 75 72 20 64 61 74 61 | 20 77 69 74 68 20 73 69 |our data| with si|
|00000c00| 6c 65 6e 63 65 20 69 66 | 20 79 6f 75 20 63 68 6f |lence if| you cho|
|00000c10| 6f 73 65 20 61 6e 20 d2 | 6f 64 64 d3 20 62 75 66 |ose an .|odd. buf|
|00000c20| 66 65 72 20 73 69 7a 65 | 2e 20 49 6e 20 74 68 65 |fer size|. In the|
|00000c30| 20 77 6f 72 73 74 20 63 | 61 73 65 20 74 68 69 73 | worst c|ase this|
|00000c40| 20 63 61 6e 20 6c 65 61 | 64 20 74 6f 20 61 6e 6e | can lea|d to ann|
|00000c50| 6f 79 69 6e 67 20 61 6e | 64 20 6d 79 73 74 65 72 |oying an|d myster|
|00000c60| 69 6f 75 73 20 73 69 6c | 65 6e 63 65 73 20 62 65 |ious sil|ences be|
|00000c70| 74 77 65 65 6e 20 62 75 | 66 66 65 72 73 2c 20 61 |tween bu|ffers, a|
|00000c80| 6e 64 20 61 74 20 62 65 | 73 74 20 69 74 20 77 69 |nd at be|st it wi|
|00000c90| 6c 6c 20 68 75 72 74 20 | 79 6f 75 72 20 70 65 72 |ll hurt |your per|
|00000ca0| 66 6f 72 6d 61 6e 63 65 | 2e 20 54 68 69 73 20 64 |formance|. This d|
|00000cb0| 6f 65 73 6e d5 74 20 6d | 65 61 6e 20 74 68 61 74 |oesn.t m|ean that|
|00000cc0| 20 79 6f 75 20 6e 65 65 | 64 20 74 6f 20 6c 69 6d | you nee|d to lim|
|00000cd0| 69 74 20 79 6f 75 72 73 | 65 6c 66 20 74 6f 20 35 |it yours|elf to 5|
|00000ce0| 31 32 2d 20 6f 72 20 31 | 30 32 34 2d 62 79 74 65 |12- or 1|024-byte|
|00000cf0| 20 62 75 66 66 65 72 73 | 3a 20 54 68 65 20 53 6f | buffers|: The So|
|00000d00| 75 6e 64 20 4d 61 6e 61 | 67 65 72 20 74 61 6b 65 |und Mana|ger take|
|00000d10| 73 20 63 61 72 65 20 6f | 66 20 66 65 65 64 69 6e |s care o|f feedin|
|00000d20| 67 20 6c 61 72 67 65 20 | 62 75 66 66 65 72 73 20 |g large |buffers |
|00000d30| 74 6f 20 74 68 65 20 41 | 53 43 20 61 20 63 68 75 |to the A|SC a chu|
|00000d40| 6e 6b 20 61 74 20 61 20 | 74 69 6d 65 20 73 6f 20 |nk at a |time so |
|00000d50| 74 68 61 74 20 79 6f 75 | 20 64 6f 6e d5 74 20 68 |that you| don.t h|
|00000d60| 61 76 65 20 74 6f 20 77 | 6f 72 72 79 20 61 62 6f |ave to w|orry abo|
|00000d70| 75 74 20 69 74 2e 20 41 | 73 20 6c 6f 6e 67 20 61 |ut it. A|s long a|
|00000d80| 73 20 79 6f 75 72 20 73 | 6f 75 6e 64 20 69 73 20 |s your s|ound is |
|00000d90| 73 6d 61 6c 6c 20 65 6e | 6f 75 67 68 20 74 6f 20 |small en|ough to |
|00000da0| 66 69 74 20 69 6e 74 6f | 20 61 76 61 69 6c 61 62 |fit into| availab|
|00000db0| 6c 65 20 6d 65 6d 6f 72 | 79 2c 20 79 6f 75 20 63 |le memor|y, you c|
|00000dc0| 61 6e 20 70 6c 61 79 20 | 69 74 20 73 69 6d 70 6c |an play |it simpl|
|00000dd0| 79 20 62 79 20 70 61 73 | 73 69 6e 67 20 74 68 65 |y by pas|sing the|
|00000de0| 20 53 6f 75 6e 64 20 4d | 61 6e 61 67 65 72 20 61 | Sound M|anager a|
|00000df0| 20 70 6f 69 6e 74 65 72 | 20 74 6f 20 74 68 65 20 | pointer| to the |
|00000e00| 62 75 66 66 65 72 20 63 | 6f 6e 74 61 69 6e 69 6e |buffer c|ontainin|
|00000e10| 67 20 74 68 65 20 73 61 | 6d 70 6c 65 2e 20 0d 41 |g the sa|mple. .A|
|00000e20| 73 73 75 6d 69 6e 67 20 | 74 68 61 74 20 74 68 65 |ssuming |that the|
|00000e30| 20 41 53 43 d5 73 20 62 | 75 66 66 65 72 73 20 6e | ASC.s b|uffers n|
|00000e40| 65 76 65 72 20 72 75 6e | 20 64 72 79 2c 20 69 74 |ever run| dry, it|
|00000e50| 20 77 69 6c 6c 20 70 72 | 6f 64 75 63 65 20 77 68 | will pr|oduce wh|
|00000e60| 61 74 20 73 65 65 6d 73 | 20 74 6f 20 62 65 20 61 |at seems| to be a|
|00000e70| 20 63 6f 6e 74 69 6e 75 | 6f 75 73 20 73 6f 75 6e | continu|ous soun|
|00000e80| 64 2e 20 41 73 20 6c 6f | 6e 67 20 61 73 20 79 6f |d. As lo|ng as yo|
|00000e90| 75 20 63 61 6e 20 6b 65 | 65 70 20 68 61 6e 64 69 |u can ke|ep handi|
|00000ea0| 6e 67 20 69 74 20 64 61 | 74 61 20 61 74 20 61 20 |ng it da|ta at a |
|00000eb0| 72 61 74 65 20 67 72 65 | 61 74 65 72 20 74 68 61 |rate gre|ater tha|
|00000ec0| 6e 20 6f 72 20 65 71 75 | 61 6c 20 74 6f 20 74 68 |n or equ|al to th|
|00000ed0| 65 20 73 70 65 65 64 20 | 61 74 20 77 68 69 63 68 |e speed |at which|
|00000ee0| 20 69 74 20 63 61 6e 20 | 70 72 6f 63 65 73 73 20 | it can |process |
|00000ef0| 74 68 65 20 64 61 74 61 | 2c 20 74 68 65 72 65 20 |the data|, there |
|00000f00| 77 6f 6e d5 74 20 62 65 | 20 61 6e 79 20 67 61 70 |won.t be| any gap|
|00000f10| 73 20 69 6e 20 74 68 65 | 20 70 6c 61 79 62 61 63 |s in the| playbac|
|00000f20| 6b 2e 20 45 76 65 6e 20 | 74 68 65 20 62 65 73 74 |k. Even |the best|
|00000f30| 2d 71 75 61 6c 69 74 79 | 20 73 61 6d 70 6c 65 73 |-quality| samples|
|00000f40| 2c 20 6c 69 6b 65 20 74 | 68 6f 73 65 20 66 6f 75 |, like t|hose fou|
|00000f50| 6e 64 20 6f 6e 20 61 75 | 64 69 6f 20 43 44 73 2c |nd on au|dio CDs,|
|00000f60| 20 70 6c 61 79 20 62 61 | 63 6b 20 61 74 20 74 68 | play ba|ck at th|
|00000f70| 65 20 6c 65 69 73 75 72 | 65 6c 79 20 72 61 74 65 |e leisur|ely rate|
|00000f80| 20 6f 66 20 34 34 2c 31 | 30 30 20 73 61 6d 70 6c | of 44,1|00 sampl|
|00000f90| 65 20 66 72 61 6d 65 73 | 20 70 65 72 20 73 65 63 |e frames| per sec|
|00000fa0| 6f 6e 64 20 28 61 20 66 | 72 61 6d 65 20 63 6f 6e |ond (a f|rame con|
|00000fb0| 73 69 73 74 73 20 6f 66 | 20 74 77 6f 20 73 61 6d |sists of| two sam|
|00000fc0| 70 6c 65 20 70 6f 69 6e | 74 73 2c 20 6f 6e 65 20 |ple poin|ts, one |
|00000fd0| 66 6f 72 20 65 61 63 68 | 20 63 68 61 6e 6e 65 6c |for each| channel|
|00000fe0| 20 6f 66 20 73 6f 75 6e | 64 29 2c 20 61 20 72 61 | of soun|d), a ra|
|00000ff0| 74 65 20 74 68 61 74 20 | 74 68 65 20 70 72 6f 63 |te that |the proc|
|00001000| 65 73 73 6f 72 73 20 6f | 66 20 36 38 30 32 30 2d |essors o|f 68020-|
|00001010| 62 61 73 65 64 20 4d 61 | 63 69 6e 74 6f 73 68 20 |based Ma|cintosh |
|00001020| 63 6f 6d 70 75 74 65 72 | 73 20 61 6e 64 20 53 43 |computer|s and SC|
|00001030| 53 49 20 64 65 76 69 63 | 65 73 20 63 61 6e 20 6b |SI devic|es can k|
|00001040| 65 65 70 20 75 70 20 77 | 69 74 68 2e 20 41 6c 6c |eep up w|ith. All|
|00001050| 20 79 6f 75 20 6e 65 65 | 64 20 74 6f 20 64 6f 20 | you nee|d to do |
|00001060| 69 73 20 68 61 6e 64 20 | 6f 6e 65 20 62 75 66 66 |is hand |one buff|
|00001070| 65 72 20 74 6f 20 74 68 | 65 20 53 6f 75 6e 64 20 |er to th|e Sound |
|00001080| 4d 61 6e 61 67 65 72 20 | 74 6f 20 70 6c 61 79 20 |Manager |to play |
|00001090| 77 68 69 6c 65 20 79 6f | 75 d5 72 65 20 66 69 6c |while yo|u.re fil|
|000010a0| 6c 69 6e 67 20 61 6e 6f | 74 68 65 72 2e 20 57 68 |ling ano|ther. Wh|
|000010b0| 65 6e 20 74 68 65 20 62 | 75 66 66 65 72 20 74 68 |en the b|uffer th|
|000010c0| 61 74 d5 73 20 63 75 72 | 72 65 6e 74 6c 79 20 70 |at.s cur|rently p|
|000010d0| 6c 61 79 69 6e 67 20 69 | 73 20 65 78 68 61 75 73 |laying i|s exhaus|
|000010e0| 74 65 64 2c 20 79 6f 75 | 20 70 61 73 73 20 74 68 |ted, you| pass th|
|000010f0| 65 20 72 65 63 65 6e 74 | 6c 79 20 66 69 6c 6c 65 |e recent|ly fille|
|00001100| 64 20 6f 6e 65 20 74 6f | 20 74 68 65 20 53 6f 75 |d one to| the Sou|
|00001110| 6e 64 20 4d 61 6e 61 67 | 65 72 20 61 6e 64 20 72 |nd Manag|er and r|
|00001120| 65 66 69 6c 6c 20 74 68 | 65 20 65 6d 70 74 79 20 |efill th|e empty |
|00001130| 6f 6e 65 2e 20 54 68 69 | 73 20 70 72 6f 63 65 73 |one. Thi|s proces|
|00001140| 73 20 69 73 20 74 68 65 | 20 64 69 67 69 74 61 6c |s is the| digital|
|00001150| 20 65 71 75 69 76 61 6c | 65 6e 74 20 6f 66 20 74 | equival|ent of t|
|00001160| 68 65 20 76 65 6e 65 72 | 61 62 6c 65 20 62 75 63 |he vener|able buc|
|00001170| 6b 65 74 20 62 72 69 67 | 61 64 65 20 74 65 63 68 |ket brig|ade tech|
|00001180| 6e 69 71 75 65 20 66 6f | 72 20 66 69 67 68 74 69 |nique fo|r fighti|
|00001190| 6e 67 20 66 69 72 65 73 | 2e 0d 43 4f 4e 54 49 4e |ng fires|..CONTIN|
|000011a0| 55 4f 55 53 20 53 4f 55 | 4e 44 20 4d 41 4e 41 47 |UOUS SOU|ND MANAG|
|000011b0| 45 4d 45 4e 54 0d 54 68 | 69 73 20 73 65 63 74 69 |EMENT.Th|is secti|
|000011c0| 6f 6e 20 64 69 73 63 75 | 73 73 65 73 20 61 20 67 |on discu|sses a g|
|000011d0| 65 6e 65 72 61 6c 20 73 | 74 72 61 74 65 67 79 20 |eneral s|trategy |
|000011e0| 66 6f 72 20 61 63 74 75 | 61 6c 6c 79 20 6d 61 6b |for actu|ally mak|
|000011f0| 69 6e 67 20 61 20 6d 75 | 6c 74 69 62 75 66 66 65 |ing a mu|ltibuffe|
|00001200| 72 69 6e 67 20 73 63 68 | 65 6d 65 20 77 6f 72 6b |ring sch|eme work|
|00001210| 2e 20 46 69 72 73 74 2c | 20 68 6f 77 65 76 65 72 |. First,| however|
|00001220| 2c 20 49 20 77 61 6e 74 | 20 74 6f 20 74 6f 75 63 |, I want| to touc|
|00001230| 68 20 6f 6e 20 73 6f 6d | 65 20 6f 66 20 74 68 65 |h on som|e of the|
|00001240| 20 70 72 6f 70 65 72 74 | 69 65 73 20 61 6e 64 20 | propert|ies and |
|00001250| 66 65 61 74 75 72 65 73 | 20 6f 66 20 74 68 65 20 |features| of the |
|00001260| 53 6f 75 6e 64 20 4d 61 | 6e 61 67 65 72 20 74 68 |Sound Ma|nager th|
|00001270| 61 74 20 77 65 d5 6c 6c | 20 65 78 70 6c 6f 69 74 |at we.ll| exploit|
|00001280| 20 74 6f 20 61 63 63 6f | 6d 70 6c 69 73 68 20 6d | to acco|mplish m|
|00001290| 75 6c 74 69 62 75 66 66 | 65 72 69 6e 67 2e 20 49 |ultibuff|ering. I|
|000012a0| 66 20 79 6f 75 d5 72 65 | 20 61 6c 72 65 61 64 79 |f you.re| already|
|000012b0| 20 66 61 6d 69 6c 69 61 | 72 20 77 69 74 68 20 74 | familia|r with t|
|000012c0| 68 65 20 53 6f 75 6e 64 | 20 4d 61 6e 61 67 65 72 |he Sound| Manager|
|000012d0| 2c 20 79 6f 75 20 6d 61 | 79 20 77 61 6e 74 20 74 |, you ma|y want t|
|000012e0| 6f 20 73 6b 69 70 20 61 | 68 65 61 64 20 74 6f 20 |o skip a|head to |
|000012f0| 74 68 65 20 73 65 63 74 | 69 6f 6e 20 d2 57 68 65 |the sect|ion .Whe|
|00001300| 6e 20 59 6f 75 d5 72 65 | 20 44 6f 6e 65 2c 20 41 |n You.re| Done, A|
|00001310| 73 6b 20 66 6f 72 20 4d | 6f 72 65 2e d3 0d 43 48 |sk for M|ore...CH|
|00001320| 41 4e 4e 45 4c 53 2c 20 | 51 55 45 55 45 53 2c 20 |ANNELS, |QUEUES, |
|00001330| 43 4f 4d 4d 41 4e 44 53 | 2c 20 41 4e 44 20 43 41 |COMMANDS|, AND CA|
|00001340| 4c 4c 42 41 43 4b 53 0d | 54 68 65 20 61 74 6f 6d |LLBACKS.|The atom|
|00001350| 69 63 20 65 6e 74 69 74 | 79 20 69 6e 20 74 68 65 |ic entit|y in the|
|00001360| 20 53 6f 75 6e 64 20 4d | 61 6e 61 67 65 72 20 69 | Sound M|anager i|
|00001370| 73 20 61 20 63 68 61 6e | 6e 65 6c 2e 20 41 20 63 |s a chan|nel. A c|
|00001380| 68 61 6e 6e 65 6c 20 69 | 73 20 65 73 73 65 6e 74 |hannel i|s essent|
|00001390| 69 61 6c 6c 79 20 61 20 | 63 6f 6d 6d 61 6e 64 20 |ially a |command |
|000013a0| 71 75 65 75 65 20 6c 69 | 6e 6b 65 64 20 74 6f 20 |queue li|nked to |
|000013b0| 61 20 73 79 6e 74 68 65 | 73 69 7a 65 72 2e 20 41 |a synthe|sizer. A|
|000013c0| 73 20 61 20 70 72 6f 67 | 72 61 6d 6d 65 72 2c 20 |s a prog|rammer, |
|000013d0| 79 6f 75 20 69 73 73 75 | 65 20 63 6f 6d 6d 61 6e |you issu|e comman|
|000013e0| 64 73 20 74 6f 20 74 68 | 65 20 63 68 61 6e 6e 65 |ds to th|e channe|
|000013f0| 6c 20 74 68 72 6f 75 67 | 68 20 74 68 65 20 53 6f |l throug|h the So|
|00001400| 75 6e 64 20 4d 61 6e 61 | 67 65 72 20 66 75 6e 63 |und Mana|ger func|
|00001410| 74 69 6f 6e 73 20 53 6e | 64 44 6f 43 6f 6d 6d 61 |tions Sn|dDoComma|
|00001420| 6e 64 20 61 6e 64 20 53 | 6e 64 44 6f 49 6d 6d 65 |nd and S|ndDoImme|
|00001430| 64 69 61 74 65 2e 20 54 | 68 65 20 53 6f 75 6e 64 |diate. T|he Sound|
|00001440| 20 4d 61 6e 61 67 65 72 | 20 65 78 65 63 75 74 65 | Manager| execute|
|00001450| 73 20 74 68 65 20 63 6f | 6d 6d 61 6e 64 73 20 61 |s the co|mmands a|
|00001460| 73 79 6e 63 68 72 6f 6e | 6f 75 73 6c 79 2c 0d 53 |synchron|ously,.S|
|00001470| 4f 55 4e 44 3a 20 20 46 | 52 4f 4d 20 50 48 59 53 |OUND: F|ROM PHYS|
|00001480| 49 43 41 4c 20 54 4f 20 | 44 49 47 49 54 41 4c 20 |ICAL TO |DIGITAL |
|00001490| 41 4e 44 20 42 41 43 4b | 0d 57 68 61 74 20 79 6f |AND BACK|.What yo|
|000014a0| 75 20 65 78 70 65 72 69 | 65 6e 63 65 20 77 68 65 |u experi|ence whe|
|000014b0| 6e 20 79 6f 75 20 68 65 | 61 72 20 61 20 73 6f 75 |n you he|ar a sou|
|000014c0| 6e 64 20 69 73 20 61 63 | 74 75 61 6c 6c 79 20 79 |nd is ac|tually y|
|000014d0| 6f 75 72 20 65 61 72 20 | 70 69 63 6b 69 6e 67 20 |our ear |picking |
|000014e0| 75 70 20 61 20 73 65 72 | 69 65 73 20 6f 66 20 70 |up a ser|ies of p|
|000014f0| 72 65 73 73 75 72 65 20 | 63 68 61 6e 67 65 73 2c |ressure |changes,|
|00001500| 20 63 6f 6d 6d 6f 6e 6c | 79 20 74 68 6f 75 67 68 | commonl|y though|
|00001510| 74 20 6f 66 20 61 73 20 | 77 61 76 65 73 2c 20 69 |t of as |waves, i|
|00001520| 6e 20 74 68 65 20 61 6d | 62 69 65 6e 74 20 61 69 |n the am|bient ai|
|00001530| 72 2e 20 54 68 72 6f 75 | 67 68 20 61 20 62 75 6e |r. Throu|gh a bun|
|00001540| 63 68 20 6f 66 20 70 68 | 79 73 69 6f 6c 6f 67 69 |ch of ph|ysiologi|
|00001550| 63 61 6c 20 6d 61 67 69 | 63 2c 20 74 68 65 20 65 |cal magi|c, the e|
|00001560| 61 72 20 63 6f 6e 76 65 | 72 74 73 20 74 68 65 73 |ar conve|rts thes|
|00001570| 65 20 70 72 65 73 73 75 | 72 65 20 63 68 61 6e 67 |e pressu|re chang|
|00001580| 65 73 20 74 6f 20 61 20 | 6e 65 75 72 61 6c 20 73 |es to a |neural s|
|00001590| 69 67 6e 61 6c 20 74 68 | 61 74 20 79 6f 75 72 20 |ignal th|at your |
|000015a0| 62 72 61 69 6e 20 63 61 | 6e 20 74 68 65 6e 20 72 |brain ca|n then r|
|000015b0| 65 63 6f 67 6e 69 7a 65 | 20 61 73 20 79 6f 75 72 |ecognize| as your|
|000015c0| 20 61 6c 61 72 6d 20 63 | 6c 6f 63 6b 20 6f 72 20 | alarm c|lock or |
|000015d0| 43 68 6f 70 69 6e 2c 20 | 64 65 70 65 6e 64 69 6e |Chopin, |dependin|
|000015e0| 67 20 6f 6e 20 74 68 65 | 20 77 61 76 65 66 6f 72 |g on the| wavefor|
|000015f0| 6d 2e 20 42 6f 74 68 20 | 74 68 65 20 77 61 76 65 |m. Both |the wave|
|00001600| 66 6f 72 6d 20 61 6e 64 | 20 69 74 73 20 6e 65 75 |form and| its neu|
|00001610| 72 61 6c 20 65 71 75 69 | 76 61 6c 65 6e 74 20 61 |ral equi|valent a|
|00001620| 72 65 20 61 6e 61 6c 6f | 67 2c 20 77 68 69 63 68 |re analo|g, which|
|00001630| 20 69 73 20 75 73 65 6c | 65 73 73 20 61 73 20 66 | is usel|ess as f|
|00001640| 61 72 20 61 73 20 79 6f | 75 72 20 63 6f 6d 70 75 |ar as yo|ur compu|
|00001650| 74 65 72 20 69 73 20 63 | 6f 6e 63 65 72 6e 65 64 |ter is c|oncerned|
|00001660| 2e 20 54 6f 20 67 65 74 | 20 74 68 65 20 61 6e 61 |. To get| the ana|
|00001670| 6c 6f 67 20 70 68 65 6e | 6f 6d 65 6e 61 20 69 6e |log phen|omena in|
|00001680| 74 6f 20 79 6f 75 72 20 | 6d 61 63 68 69 6e 65 2c |to your |machine,|
|00001690| 20 79 6f 75 20 6e 65 65 | 64 20 74 6f 20 75 73 65 | you nee|d to use|
|000016a0| 20 73 6f 6d 65 20 73 6f | 72 74 20 6f 66 20 74 72 | some so|rt of tr|
|000016b0| 61 6e 73 64 75 63 65 72 | 20 28 61 20 6d 69 63 72 |ansducer| (a micr|
|000016c0| 6f 70 68 6f 6e 65 2c 20 | 66 6f 72 20 69 6e 73 74 |ophone, |for inst|
|000016d0| 61 6e 63 65 29 20 61 6e | 64 20 61 6e 20 61 6e 61 |ance) an|d an ana|
|000016e0| 6c 6f 67 2d 74 6f 2d 64 | 69 67 69 74 61 6c 20 63 |log-to-d|igital c|
|000016f0| 6f 6e 76 65 72 74 65 72 | 20 73 75 63 68 20 61 73 |onverter| such as|
|00001700| 20 74 68 65 20 73 6f 75 | 6e 64 20 69 6e 70 75 74 | the sou|nd input|
|00001710| 20 68 61 72 64 77 61 72 | 65 20 66 6f 75 6e 64 20 | hardwar|e found |
|00001720| 69 6e 20 6d 6f 73 74 20 | 4d 61 63 69 6e 74 6f 73 |in most |Macintos|
|00001730| 68 20 6d 6f 64 65 6c 73 | 2e 0d 4c 69 6b 65 20 79 |h models|..Like y|
|00001740| 6f 75 72 20 65 61 72 2c | 20 74 68 65 20 6d 69 63 |our ear,| the mic|
|00001750| 72 6f 70 68 6f 6e 65 20 | 70 69 63 6b 73 20 75 70 |rophone |picks up|
|00001760| 20 6d 69 6e 75 74 65 20 | 70 72 65 73 73 75 72 65 | minute |pressure|
|00001770| 20 63 68 61 6e 67 65 73 | 20 69 6e 20 74 68 65 20 | changes| in the |
|00001780| 61 69 72 2c 20 62 75 74 | 20 69 74 20 70 72 6f 64 |air, but| it prod|
|00001790| 75 63 65 73 20 61 6e 20 | 65 6c 65 63 74 72 69 63 |uces an |electric|
|000017a0| 61 6c 20 73 69 67 6e 61 | 6c 20 74 68 61 74 20 74 |al signa|l that t|
|000017b0| 68 65 20 61 6e 61 6c 6f | 67 2d 74 6f 2d 64 69 67 |he analo|g-to-dig|
|000017c0| 69 74 61 6c 20 63 6f 6e | 76 65 72 74 65 72 20 74 |ital con|verter t|
|000017d0| 75 72 6e 73 20 69 6e 74 | 6f 20 61 20 73 74 72 65 |urns int|o a stre|
|000017e0| 61 6d 20 6f 66 20 6e 75 | 6d 62 65 72 73 20 63 6f |am of nu|mbers co|
|000017f0| 72 72 65 73 70 6f 6e 64 | 69 6e 67 20 74 6f 20 74 |rrespond|ing to t|
|00001800| 68 65 20 76 6f 6c 74 61 | 67 65 20 28 61 6d 70 6c |he volta|ge (ampl|
|00001810| 69 74 75 64 65 29 20 6f | 66 20 74 68 65 20 73 69 |itude) o|f the si|
|00001820| 67 6e 61 6c 2e 20 45 61 | 63 68 20 6f 66 20 74 68 |gnal. Ea|ch of th|
|00001830| 65 73 65 20 6e 75 6d 62 | 65 72 73 20 69 73 20 61 |ese numb|ers is a|
|00001840| 20 64 69 73 63 72 65 74 | 65 20 73 61 6d 70 6c 65 | discret|e sample|
|00001850| 20 70 6f 69 6e 74 2c 20 | 61 6e 64 20 74 68 65 20 | point, |and the |
|00001860| 63 6f 6c 6c 65 63 74 69 | 6f 6e 20 6f 66 20 73 61 |collecti|on of sa|
|00001870| 6d 70 6c 65 20 70 6f 69 | 6e 74 73 20 74 68 61 74 |mple poi|nts that|
|00001880| 20 64 65 66 69 6e 65 20 | 74 68 65 20 77 61 76 65 | define |the wave|
|00001890| 66 6f 72 6d 20 61 72 65 | 20 63 6f 6c 6c 65 63 74 |form are| collect|
|000018a0| 69 76 65 6c 79 20 6b 6e | 6f 77 6e 20 61 73 20 61 |ively kn|own as a|
|000018b0| 20 73 61 6d 70 6c 65 2e | 20 0d 49 6e 20 61 6e 20 | sample.| .In an |
|000018c0| 69 64 65 61 6c 20 77 6f | 72 6c 64 20 79 6f 75 72 |ideal wo|rld your|
|000018d0| 20 73 61 6d 70 6c 65 20 | 77 6f 75 6c 64 20 62 65 | sample |would be|
|000018e0| 20 63 6f 6e 74 69 6e 75 | 6f 75 73 2c 20 6d 65 61 | continu|ous, mea|
|000018f0| 6e 69 6e 67 20 74 68 61 | 74 20 74 68 65 72 65 20 |ning tha|t there |
|00001900| 77 6f 75 6c 64 20 62 65 | 20 61 6e 20 69 6e 66 69 |would be| an infi|
|00001910| 6e 69 74 65 20 6e 75 6d | 62 65 72 20 6f 66 20 73 |nite num|ber of s|
|00001920| 61 6d 70 6c 65 20 70 6f | 69 6e 74 73 20 66 6f 72 |ample po|ints for|
|00001930| 20 61 6e 79 20 67 69 76 | 65 6e 20 74 69 6d 65 20 | any giv|en time |
|00001940| 70 65 72 69 6f 64 2e 20 | 54 68 65 20 72 65 61 6c |period. |The real|
|00001950| 69 74 79 20 69 73 20 74 | 68 61 74 20 61 6e 61 6c |ity is t|hat anal|
|00001960| 6f 67 2d 74 6f 2d 64 69 | 67 69 74 61 6c 20 28 61 |og-to-di|gital (a|
|00001970| 6e 64 20 64 69 67 69 74 | 61 6c 2d 74 6f 2d 61 6e |nd digit|al-to-an|
|00001980| 61 6c 6f 67 29 20 63 6f | 6e 76 65 72 74 65 72 73 |alog) co|nverters|
|00001990| 20 63 61 6e 20 68 61 6e | 64 6c 65 20 6f 6e 6c 79 | can han|dle only|
|000019a0| 20 61 20 66 69 6e 69 74 | 65 20 6e 75 6d 62 65 72 | a finit|e number|
|000019b0| 20 6f 66 20 73 61 6d 70 | 6c 65 20 70 6f 69 6e 74 | of samp|le point|
|000019c0| 73 20 70 65 72 20 73 65 | 63 6f 6e 64 2c 20 73 6f |s per se|cond, so|
|000019d0| 20 74 68 65 20 63 6f 6e | 63 65 70 74 20 6f 66 20 | the con|cept of |
|000019e0| 73 61 6d 70 6c 65 20 66 | 72 65 71 75 65 6e 63 79 |sample f|requency|
|000019f0| 20 62 65 63 6f 6d 65 73 | 20 69 6d 70 6f 72 74 61 | becomes| importa|
|00001a00| 6e 74 2e 20 54 68 65 20 | 68 69 67 68 65 72 20 74 |nt. The |higher t|
|00001a10| 68 65 20 66 72 65 71 75 | 65 6e 63 79 2c 20 74 68 |he frequ|ency, th|
|00001a20| 65 20 62 65 74 74 65 72 | 20 74 68 65 20 73 61 6d |e better| the sam|
|00001a30| 70 6c 65 20 61 70 70 72 | 6f 78 69 6d 61 74 65 73 |ple appr|oximates|
|00001a40| 20 74 68 65 20 6f 72 69 | 67 69 6e 61 6c 20 77 61 | the ori|ginal wa|
|00001a50| 76 65 66 6f 72 6d 2e 20 | 54 68 65 20 73 61 6d 70 |veform. |The samp|
|00001a60| 6c 65 20 66 72 65 71 75 | 65 6e 63 79 20 69 73 20 |le frequ|ency is |
|00001a70| 75 73 75 61 6c 6c 79 20 | 65 78 70 72 65 73 73 65 |usually |expresse|
|00001a80| 64 20 69 6e 20 6b 69 6c | 6f 68 65 72 74 7a 2c 20 |d in kil|ohertz, |
|00001a90| 77 68 69 63 68 20 67 69 | 76 65 73 20 74 68 65 20 |which gi|ves the |
|00001aa0| 6e 75 6d 62 65 72 20 6f | 66 20 73 61 6d 70 6c 65 |number o|f sample|
|00001ab0| 20 70 6f 69 6e 74 73 20 | 70 65 72 20 6d 69 63 72 | points |per micr|
|00001ac0| 6f 73 65 63 6f 6e 64 2e | 20 43 6f 6d 6d 6f 6e 20 |osecond.| Common |
|00001ad0| 73 61 6d 70 6c 65 20 72 | 61 74 65 73 20 61 72 65 |sample r|ates are|
|00001ae0| 20 37 20 6b 48 7a 2c 20 | 31 31 20 6b 48 7a 2c 20 | 7 kHz, |11 kHz, |
|00001af0| 61 6e 64 20 32 32 20 6b | 48 7a 2c 20 74 68 6f 75 |and 22 k|Hz, thou|
|00001b00| 67 68 20 74 68 65 20 53 | 6f 75 6e 64 20 4d 61 6e |gh the S|ound Man|
|00001b10| 61 67 65 72 20 63 75 72 | 72 65 6e 74 6c 79 20 73 |ager cur|rently s|
|00001b20| 75 70 70 6f 72 74 73 20 | 61 6e 79 20 73 61 6d 70 |upports |any samp|
|00001b30| 6c 65 20 72 61 74 65 73 | 20 62 65 74 77 65 65 6e |le rates| between|
|00001b40| 20 31 20 6b 48 7a 20 61 | 6e 64 20 32 32 20 6b 48 | 1 kHz a|nd 22 kH|
|00001b50| 7a 2e 20 49 6e 20 70 72 | 61 63 74 69 63 65 2c 20 |z. In pr|actice, |
|00001b60| 69 74 d5 73 20 62 65 73 | 74 20 74 6f 20 73 74 69 |it.s bes|t to sti|
|00001b70| 63 6b 20 74 6f 20 61 6e | 20 65 76 65 6e 20 64 69 |ck to an| even di|
|00001b80| 76 69 73 6f 72 20 6f 66 | 20 32 32 20 6b 48 7a 2c |visor of| 22 kHz,|
|00001b90| 20 73 69 6e 63 65 20 69 | 74 20 6d 69 6e 69 6d 69 | since i|t minimi|
|00001ba0| 7a 65 73 20 74 68 65 20 | 6e 75 6d 62 65 72 20 6f |zes the |number o|
|00001bb0| 66 20 68 6f 6f 70 73 20 | 74 68 65 20 73 6f 66 74 |f hoops |the soft|
|00001bc0| 77 61 72 65 20 6e 65 65 | 64 73 20 74 6f 20 6a 75 |ware nee|ds to ju|
|00001bd0| 6d 70 20 74 68 72 6f 75 | 67 68 20 74 6f 20 70 6c |mp throu|gh to pl|
|00001be0| 61 79 20 79 6f 75 72 20 | 73 6f 75 6e 64 2e 20 0d |ay your |sound. .|
|00001bf0| 41 6e 6f 74 68 65 72 20 | 66 61 63 74 6f 72 20 74 |Another |factor t|
|00001c00| 68 61 74 20 61 66 66 65 | 63 74 73 20 74 68 65 20 |hat affe|cts the |
|00001c10| 66 69 64 65 6c 69 74 79 | 20 6f 66 20 74 68 65 20 |fidelity| of the |
|00001c20| 73 61 6d 70 6c 65 20 69 | 73 20 69 74 73 20 71 75 |sample i|s its qu|
|00001c30| 61 6e 74 69 7a 61 74 69 | 6f 6e 2c 20 77 68 69 63 |antizati|on, whic|
|00001c40| 68 20 69 73 20 72 65 6c | 61 74 65 64 20 74 6f 20 |h is rel|ated to |
|00001c50| 68 6f 77 20 6d 61 6e 79 | 20 62 69 74 73 20 61 72 |how many| bits ar|
|00001c60| 65 20 75 73 65 64 0d 74 | 6f 20 64 65 73 63 72 69 |e used.t|o descri|
|00001c70| 62 65 20 65 61 63 68 20 | 73 61 6d 70 6c 65 20 70 |be each |sample p|
|00001c80| 69 6f 6e 74 2e 20 54 68 | 65 20 53 6f 75 6e 64 20 |iont. Th|e Sound |
|00001c90| 4d 61 6e 61 67 65 72 20 | 63 75 72 72 65 6e 74 6c |Manager |currentl|
|00001ca0| 79 20 73 75 70 70 6f 72 | 74 73 20 6f 6e 6c 79 20 |y suppor|ts only |
|00001cb0| 38 2d 62 69 74 20 73 61 | 6d 70 6c 65 73 2c 20 77 |8-bit sa|mples, w|
|00001cc0| 68 69 63 68 20 69 73 20 | 73 75 66 66 69 63 69 65 |hich is |sufficie|
|00001cd0| 6e 74 20 66 6f 72 20 6d | 6f 73 74 20 61 70 70 6c |nt for m|ost appl|
|00001ce0| 69 63 61 74 69 6f 6e 73 | 2e 0d 54 68 65 20 64 69 |ications|..The di|
|00001cf0| 67 69 74 69 7a 65 64 20 | 73 6f 75 6e 64 20 69 73 |gitized |sound is|
|00001d00| 20 73 74 6f 72 65 64 20 | 65 69 74 68 65 72 20 69 | stored |either i|
|00001d10| 6e 20 6d 65 6d 6f 72 79 | 20 6f 72 20 6f 6e 20 61 |n memory| or on a|
|00001d20| 20 6d 6f 72 65 20 70 65 | 72 6d 61 6e 65 6e 74 20 | more pe|rmanent |
|00001d30| 73 74 6f 72 61 67 65 20 | 6d 65 64 69 75 6d 20 73 |storage |medium s|
|00001d40| 75 63 68 20 61 73 20 61 | 20 68 61 72 64 20 64 69 |uch as a| hard di|
|00001d50| 73 6b 20 6f 72 20 43 44 | 2d 52 4f 4d 2e 20 54 68 |sk or CD|-ROM. Th|
|00001d60| 65 20 69 6d 70 6f 72 74 | 61 6e 74 20 74 68 69 6e |e import|ant thin|
|00001d70| 67 20 74 6f 20 74 61 6b | 65 20 61 77 61 79 20 66 |g to tak|e away f|
|00001d80| 72 6f 6d 20 74 68 69 73 | 20 64 69 73 63 75 73 73 |rom this| discuss|
|00001d90| 69 6f 6e 20 69 73 20 74 | 68 61 74 20 69 6e 20 6f |ion is t|hat in o|
|00001da0| 72 64 65 72 20 74 6f 20 | 67 65 74 20 68 69 67 68 |rder to |get high|
|00001db0| 2d 71 75 61 6c 69 74 79 | 20 73 61 6d 70 6c 65 73 |-quality| samples|
|00001dc0| 2c 20 79 6f 75 20 6e 65 | 65 64 20 74 6f 20 68 61 |, you ne|ed to ha|
|00001dd0| 76 65 20 61 20 68 69 67 | 68 20 73 61 6d 70 6c 69 |ve a hig|h sampli|
|00001de0| 6e 67 20 72 61 74 65 20 | 61 6e 64 20 61 20 72 65 |ng rate |and a re|
|00001df0| 61 73 6f 6e 61 62 6c 65 | 20 73 61 6d 70 6c 65 20 |asonable| sample |
|00001e00| 73 69 7a 65 20 28 72 65 | 61 64 3a 20 6c 6f 74 73 |size (re|ad: lots|
|00001e10| 20 6f 66 20 6d 65 6d 6f | 72 79 29 2e 0d 43 6f 6e | of memo|ry)..Con|
|00001e20| 76 65 72 74 69 6e 67 20 | 73 61 6d 70 6c 65 73 20 |verting |samples |
|00001e30| 62 61 63 6b 20 69 6e 74 | 6f 20 73 6f 75 6e 64 20 |back int|o sound |
|00001e40| 69 73 20 65 78 61 63 74 | 6c 79 20 74 68 65 20 72 |is exact|ly the r|
|00001e50| 65 76 65 72 73 65 20 6f | 66 20 74 68 65 20 72 65 |everse o|f the re|
|00001e60| 63 6f 72 64 69 6e 67 20 | 70 72 6f 63 65 73 73 2e |cording |process.|
|00001e70| 20 54 68 65 20 64 61 74 | 61 20 67 6f 65 73 20 74 | The dat|a goes t|
|00001e80| 6f 20 61 20 64 69 67 69 | 74 61 6c 2d 74 6f 2d 61 |o a digi|tal-to-a|
|00001e90| 6e 61 6c 6f 67 20 63 6f | 6e 76 65 72 74 65 72 2c |nalog co|nverter,|
|00001ea0| 20 77 68 69 63 68 20 67 | 65 6e 65 72 61 74 65 73 | which g|enerates|
|00001eb0| 20 61 20 73 70 65 63 69 | 66 69 63 20 76 6f 6c 74 | a speci|fic volt|
|00001ec0| 61 67 65 20 62 61 73 65 | 64 20 6f 6e 20 74 68 65 |age base|d on the|
|00001ed0| 20 64 69 67 69 74 61 6c | 20 76 61 6c 75 65 20 68 | digital| value h|
|00001ee0| 61 6e 64 65 64 20 74 6f | 20 69 74 2e 20 41 66 74 |anded to| it. Aft|
|00001ef0| 65 72 20 73 6f 6d 65 20 | 73 6f 72 74 20 6f 66 20 |er some |sort of |
|00001f00| 61 6d 70 6c 69 66 69 63 | 61 74 69 6f 6e 2c 20 74 |amplific|ation, t|
|00001f10| 68 65 73 65 20 76 6f 6c | 74 61 67 65 73 20 63 61 |hese vol|tages ca|
|00001f20| 75 73 65 20 61 20 73 70 | 65 61 6b 65 72 20 74 6f |use a sp|eaker to|
|00001f30| 20 65 6d 69 74 20 61 6e | 20 d2 69 6d 61 67 65 d3 | emit an| .image.|
|00001f40| 20 6f 66 20 74 68 65 20 | 6f 72 69 67 69 6e 61 6c | of the |original|
|00001f50| 6c 79 20 73 61 6d 70 6c | 65 64 20 77 61 76 65 66 |ly sampl|ed wavef|
|00001f60| 6f 72 6d 2e 0d 54 68 65 | 20 66 6f 6c 6c 6f 77 69 |orm..The| followi|
|00001f70| 6e 67 20 66 69 67 75 72 | 65 20 73 68 6f 77 73 20 |ng figur|e shows |
|00001f80| 61 20 31 2d 6d 69 63 72 | 6f 73 65 63 6f 6e 64 20 |a 1-micr|osecond |
|00001f90| 73 6e 61 70 73 68 6f 74 | 20 6f 66 20 61 20 77 61 |snapshot| of a wa|
|00001fa0| 76 65 66 6f 72 6d 20 73 | 61 6d 70 6c 65 64 20 61 |veform s|ampled a|
|00001fb0| 74 20 61 20 72 61 74 65 | 20 6f 66 20 32 32 20 6b |t a rate| of 22 k|
|00001fc0| 48 7a 20 61 6e 64 20 64 | 69 67 69 74 69 7a 65 64 |Hz and d|igitized|
|00001fd0| 20 61 74 20 73 61 6d 70 | 6c 65 20 73 69 7a 65 73 | at samp|le sizes|
|00001fe0| 20 6f 66 20 38 20 61 6e | 64 20 31 36 20 62 69 74 | of 8 an|d 16 bit|
|00001ff0| 73 2e 20 54 68 65 20 64 | 6f 74 73 20 73 68 6f 77 |s. The d|ots show|
|00002000| 20 68 6f 77 20 6d 75 63 | 68 20 74 68 65 20 64 69 | how muc|h the di|
|00002010| 67 69 74 69 7a 65 64 20 | 77 61 76 65 66 6f 72 6d |gitized |waveform|
|00002020| 20 63 61 6e 20 76 61 72 | 79 20 66 72 6f 6d 20 74 | can var|y from t|
|00002030| 68 65 20 6f 72 69 67 69 | 6e 61 6c 20 77 61 76 65 |he origi|nal wave|
|00002040| 66 6f 72 6d 20 61 74 20 | 65 61 63 68 20 73 61 6d |form at |each sam|
|00002050| 70 6c 65 20 73 69 7a 65 | 2e 20 54 68 65 20 31 36 |ple size|. The 16|
|00002060| 2d 62 69 74 20 73 69 7a | 65 20 67 69 76 65 73 20 |-bit siz|e gives |
|00002070| 61 20 62 65 74 74 65 72 | 20 61 70 70 72 6f 78 69 |a better| approxi|
|00002080| 6d 61 74 69 6f 6e 20 6f | 66 20 74 68 65 20 6f 72 |mation o|f the or|
|00002090| 69 67 69 6e 61 6c 20 77 | 61 76 65 66 6f 72 6d 2c |iginal w|aveform,|
|000020a0| 20 62 75 74 20 65 61 74 | 73 20 75 70 20 61 20 6c | but eat|s up a l|
|000020b0| 6f 74 20 6f 66 20 6d 65 | 6d 6f 72 79 2e 0d 72 65 |ot of me|mory..re|
|000020c0| 74 75 72 6e 69 6e 67 20 | 63 6f 6e 74 72 6f 6c 20 |turning |control |
|000020d0| 74 6f 20 74 68 65 20 63 | 61 6c 6c 65 72 20 73 6f |to the c|aller so|
|000020e0| 20 74 68 61 74 20 79 6f | 75 72 20 61 70 70 6c 69 | that yo|ur appli|
|000020f0| 63 61 74 69 6f 6e 20 63 | 61 6e 20 63 6f 6e 74 69 |cation c|an conti|
|00002100| 6e 75 65 20 77 69 74 68 | 20 69 74 73 20 77 6f 72 |nue with| its wor|
|00002110| 6b 2e 20 54 68 65 20 64 | 69 66 66 65 72 65 6e 63 |k. The d|ifferenc|
|00002120| 65 20 62 65 74 77 65 65 | 6e 20 74 68 65 20 74 77 |e betwee|n the tw|
|00002130| 6f 20 66 75 6e 63 74 69 | 6f 6e 73 20 69 73 20 74 |o functi|ons is t|
|00002140| 68 61 74 20 53 6e 64 44 | 6f 43 6f 6d 6d 61 6e 64 |hat SndD|oCommand|
|00002150| 20 77 69 6c 6c 20 61 6c | 77 61 79 73 20 61 64 64 | will al|ways add|
|00002160| 20 79 6f 75 72 20 72 65 | 71 75 65 73 74 20 74 6f | your re|quest to|
|00002170| 20 61 20 71 75 65 75 65 | 2c 20 77 68 65 72 65 61 | a queue|, wherea|
|00002180| 73 20 53 6e 64 44 6f 49 | 6d 6d 65 64 69 61 74 65 |s SndDoI|mmediate|
|00002190| 20 62 79 70 61 73 73 65 | 73 20 74 68 65 20 71 75 | bypasse|s the qu|
|000021a0| 65 75 69 6e 67 20 6d 65 | 63 68 61 6e 69 73 6d 20 |euing me|chanism |
|000021b0| 61 6e 64 20 65 78 65 63 | 75 74 65 73 20 74 68 65 |and exec|utes the|
|000021c0| 20 72 65 71 75 65 73 74 | 20 69 6d 6d 65 64 69 61 | request| immedia|
|000021d0| 74 65 6c 79 2e 20 49 74 | d5 73 20 69 6d 70 6f 72 |tely. It|.s impor|
|000021e0| 74 61 6e 74 20 74 6f 20 | 75 6e 64 65 72 73 74 61 |tant to |understa|
|000021f0| 6e 64 20 74 68 61 74 20 | 61 74 20 74 68 65 20 6c |nd that |at the l|
|00002200| 6f 77 65 73 74 20 6c 65 | 76 65 6c 20 74 68 65 20 |owest le|vel the |
|00002210| 53 6f 75 6e 64 20 4d 61 | 6e 61 67 65 72 20 61 6c |Sound Ma|nager al|
|00002220| 77 61 79 73 20 65 78 65 | 63 75 74 65 73 20 61 73 |ways exe|cutes as|
|00002230| 79 6e 63 68 72 6f 6e 6f | 75 73 6c 79 d1 79 6f 75 |ynchrono|usly.you|
|00002240| 72 20 70 72 6f 67 72 61 | 6d 20 72 65 67 61 69 6e |r progra|m regain|
|00002250| 73 20 63 6f 6e 74 72 6f | 6c 20 69 6d 6d 65 64 69 |s contro|l immedi|
|00002260| 61 74 65 6c 79 2c 20 77 | 68 65 74 68 65 72 20 74 |ately, w|hether t|
|00002270| 68 65 20 63 61 6c 6c 20 | 69 73 20 71 75 65 75 65 |he call |is queue|
|00002280| 64 20 6f 72 20 6e 6f 74 | 2e 0d 57 65 d5 72 65 20 |d or not|..We.re |
|00002290| 69 6e 74 65 72 65 73 74 | 65 64 20 68 65 72 65 20 |interest|ed here |
|000022a0| 69 6e 20 74 77 6f 20 73 | 6f 75 6e 64 20 63 6f 6d |in two s|ound com|
|000022b0| 6d 61 6e 64 73 2c 20 62 | 75 66 66 65 72 43 6d 64 |mands, b|ufferCmd|
|000022c0| 20 61 6e 64 20 63 61 6c | 6c 42 61 63 6b 43 6d 64 | and cal|lBackCmd|
|000022d0| 2e 0d a5 09 62 75 66 66 | 65 72 43 6d 64 20 73 65 |....buff|erCmd se|
|000022e0| 6e 64 73 20 61 20 62 75 | 66 66 65 72 20 6f 66 66 |nds a bu|ffer off|
|000022f0| 20 74 6f 20 74 68 65 20 | 53 6f 75 6e 64 20 4d 61 | to the |Sound Ma|
|00002300| 6e 61 67 65 72 20 74 6f | 20 62 65 20 70 6c 61 79 |nager to| be play|
|00002310| 65 64 2e 20 54 68 65 20 | 62 75 66 66 65 72 20 63 |ed. The |buffer c|
|00002320| 6f 6e 74 61 69 6e 73 20 | 6e 6f 74 20 6f 6e 6c 79 |ontains |not only|
|00002330| 20 74 68 65 20 73 61 6d | 70 6c 65 2c 20 62 75 74 | the sam|ple, but|
|00002340| 20 61 6c 73 6f 20 61 20 | 68 65 61 64 65 72 20 74 | also a |header t|
|00002350| 68 61 74 20 64 65 73 63 | 72 69 62 65 73 20 74 68 |hat desc|ribes th|
|00002360| 65 20 63 68 61 72 61 63 | 74 65 72 69 73 74 69 63 |e charac|teristic|
|00002370| 73 20 6f 66 20 74 68 65 | 20 73 6f 75 6e 64 2c 20 |s of the| sound, |
|00002380| 73 75 63 68 20 61 73 20 | 74 68 65 20 6c 65 6e 67 |such as |the leng|
|00002390| 74 68 20 6f 66 20 74 68 | 65 20 73 61 6d 70 6c 65 |th of th|e sample|
|000023a0| 2c 20 74 68 65 20 72 61 | 74 65 20 61 74 20 77 68 |, the ra|te at wh|
|000023b0| 69 63 68 20 69 74 20 77 | 61 73 20 73 61 6d 70 6c |ich it w|as sampl|
|000023c0| 65 64 2c 20 61 6e 64 20 | 73 6f 20 6f 6e 2e 20 0d |ed, and |so on. .|
|000023d0| a5 09 63 61 6c 6c 42 61 | 63 6b 43 6d 64 20 63 61 |..callBa|ckCmd ca|
|000023e0| 75 73 65 73 20 74 68 65 | 20 53 6f 75 6e 64 20 4d |uses the| Sound M|
|000023f0| 61 6e 61 67 65 72 20 74 | 6f 20 65 78 65 63 75 74 |anager t|o execut|
|00002400| 65 20 61 20 75 73 65 72 | 2d 64 65 66 69 6e 65 64 |e a user|-defined|
|00002410| 20 72 6f 75 74 69 6e 65 | 2e 20 59 6f 75 20 73 70 | routine|. You sp|
|00002420| 65 63 69 66 79 20 74 68 | 69 73 20 72 6f 75 74 69 |ecify th|is routi|
|00002430| 6e 65 20 77 68 65 6e 20 | 79 6f 75 20 69 6e 69 74 |ne when |you init|
|00002440| 69 61 6c 69 7a 65 20 74 | 68 65 20 73 6f 75 6e 64 |ialize t|he sound|
|00002450| 20 63 68 61 6e 6e 65 6c | 20 77 69 74 68 20 74 68 | channel| with th|
|00002460| 65 20 53 6f 75 6e 64 20 | 4d 61 6e 61 67 65 72 20 |e Sound |Manager |
|00002470| 66 75 6e 63 74 69 6f 6e | 20 53 6e 64 4e 65 77 43 |function| SndNewC|
|00002480| 68 61 6e 6e 65 6c 2e 20 | 42 65 20 61 77 61 72 65 |hannel. |Be aware|
|00002490| 20 74 68 61 74 20 74 68 | 65 20 72 6f 75 74 69 6e | that th|e routin|
|000024a0| 65 20 79 6f 75 20 73 70 | 65 63 69 66 79 20 65 78 |e you sp|ecify ex|
|000024b0| 65 63 75 74 65 73 20 61 | 74 20 69 6e 74 65 72 72 |ecutes a|t interr|
|000024c0| 75 70 74 20 74 69 6d 65 | 2c 20 73 6f 20 79 6f 75 |upt time|, so you|
|000024d0| 72 20 61 70 70 6c 69 63 | 61 74 69 6f 6e d5 73 20 |r applic|ation.s |
|000024e0| 67 6c 6f 62 61 6c 73 20 | 77 6f 6e d5 74 20 62 65 |globals |won.t be|
|000024f0| 20 69 6e 74 61 63 74 2c | 20 61 6e 64 20 74 68 65 | intact,| and the|
|00002500| 20 72 75 6c 65 73 20 72 | 65 67 61 72 64 69 6e 67 | rules r|egarding|
|00002510| 20 77 68 61 74 20 79 6f | 75 20 63 61 6e 20 61 6e | what yo|u can an|
|00002520| 64 20 63 61 6e d5 74 20 | 64 6f 20 61 74 20 69 6e |d can.t |do at in|
|00002530| 74 65 72 72 75 70 74 20 | 74 69 6d 65 20 64 65 66 |terrupt |time def|
|00002540| 69 6e 69 74 65 6c 79 20 | 61 70 70 6c 79 2e 0d 57 |initely |apply..W|
|00002550| 48 45 4e 20 59 4f 55 27 | 52 45 20 44 4f 4e 45 2c |HEN YOU'|RE DONE,|
|00002560| 20 41 53 4b 20 46 4f 52 | 20 4d 4f 52 45 0d 54 68 | ASK FOR| MORE.Th|
|00002570| 65 20 6b 65 79 20 74 6f | 20 61 63 68 69 65 76 69 |e key to| achievi|
|00002580| 6e 67 20 63 6f 6e 74 69 | 6e 75 6f 75 73 20 70 6c |ng conti|nuous pl|
|00002590| 61 79 62 61 63 6b 20 6f | 66 20 79 6f 75 72 20 73 |ayback o|f your s|
|000025a0| 61 6d 70 6c 65 73 20 69 | 73 20 61 6c 77 61 79 73 |amples i|s always|
|000025b0| 20 74 6f 20 68 61 76 65 | 20 64 61 74 61 20 61 76 | to have| data av|
|000025c0| 61 69 6c 61 62 6c 65 20 | 74 6f 20 74 68 65 20 41 |ailable |to the A|
|000025d0| 53 43 2e 20 54 6f 20 6b | 65 65 70 20 74 68 65 20 |SC. To k|eep the |
|000025e0| 41 53 43 20 68 61 70 70 | 69 6c 79 20 66 65 64 20 |ASC happ|ily fed |
|000025f0| 77 69 74 68 20 64 61 74 | 61 2c 20 79 6f 75 72 20 |with dat|a, your |
|00002600| 63 6f 64 65 20 6e 65 65 | 64 73 20 74 6f 20 6b 6e |code nee|ds to kn|
|00002610| 6f 77 20 77 68 65 6e 20 | 74 68 65 20 63 75 72 72 |ow when |the curr|
|00002620| 65 6e 74 20 62 75 66 66 | 65 72 20 69 73 20 65 78 |ent buff|er is ex|
|00002630| 68 61 75 73 74 65 64 2c | 20 73 6f 20 74 68 61 74 |hausted,| so that|
|00002640| 20 69 74 20 63 61 6e 20 | 62 65 20 74 68 65 72 65 | it can |be there|
|00002650| 20 74 6f 20 68 61 6e 64 | 20 6f 76 65 72 20 61 6e | to hand| over an|
|00002660| 6f 74 68 65 72 20 62 75 | 66 66 65 72 2e 20 4d 6f |other bu|ffer. Mo|
|00002670| 73 74 20 61 73 79 6e 63 | 68 72 6f 6e 6f 75 73 20 |st async|hronous |
|00002680| 49 2f 4f 20 73 79 73 74 | 65 6d 73 20 70 72 6f 76 |I/O syst|ems prov|
|00002690| 69 64 65 20 63 6f 6d 70 | 6c 65 74 69 6f 6e 20 72 |ide comp|letion r|
|000026a0| 6f 75 74 69 6e 65 73 20 | 74 68 61 74 20 6e 6f 74 |outines |that not|
|000026b0| 69 66 79 20 74 68 65 20 | 61 70 70 6c 69 63 61 74 |ify the |applicat|
|000026c0| 69 6f 6e 20 77 68 65 6e | 20 61 6e 20 65 76 65 6e |ion when| an even|
|000026d0| 74 20 74 65 72 6d 69 6e | 61 74 65 73 2e 20 55 6e |t termin|ates. Un|
|000026e0| 66 6f 72 74 75 6e 61 74 | 65 6c 79 2c 20 73 75 63 |fortunat|ely, suc|
|000026f0| 68 20 61 20 72 6f 75 74 | 69 6e 65 20 69 73 20 6e |h a rout|ine is n|
|00002700| 6f 74 20 69 6e 63 6c 75 | 64 65 64 20 69 6e 20 74 |ot inclu|ded in t|
|00002710| 68 65 20 63 75 72 72 65 | 6e 74 20 69 6e 63 61 72 |he curre|nt incar|
|00002720| 6e 61 74 69 6f 6e 20 6f | 66 20 74 68 65 20 6f 75 |nation o|f the ou|
|00002730| 74 70 75 74 20 70 6f 72 | 74 69 6f 6e 20 6f 66 20 |tput por|tion of |
|00002740| 74 68 65 20 53 6f 75 6e | 64 20 4d 61 6e 61 67 65 |the Soun|d Manage|
|00002750| 72 2e 20 49 6e 20 74 68 | 65 20 61 62 73 65 6e 63 |r. In th|e absenc|
|00002760| 65 20 6f 66 20 61 20 63 | 6f 6d 70 6c 65 74 69 6f |e of a c|ompletio|
|00002770| 6e 20 72 6f 75 74 69 6e | 65 2c 20 74 68 65 20 62 |n routin|e, the b|
|00002780| 65 73 74 20 77 61 79 20 | 74 6f 20 61 63 63 6f 6d |est way |to accom|
|00002790| 70 6c 69 73 68 20 74 68 | 69 73 20 74 79 70 65 20 |plish th|is type |
|000027a0| 6f 66 20 6e 6f 74 69 66 | 69 63 61 74 69 6f 6e 20 |of notif|ication |
|000027b0| 69 73 20 74 6f 20 71 75 | 65 75 65 20 61 20 63 61 |is to qu|eue a ca|
|000027c0| 6c 6c 42 61 63 6b 43 6d | 64 20 69 6d 6d 65 64 69 |llBackCm|d immedi|
|000027d0| 61 74 65 6c 79 20 66 6f | 6c 6c 6f 77 69 6e 67 20 |ately fo|llowing |
|000027e0| 61 20 62 75 66 66 65 72 | 43 6d 64 2e 20 46 6f 72 |a buffer|Cmd. For|
|000027f0| 20 74 68 65 20 70 75 72 | 70 6f 73 65 20 6f 66 20 | the pur|pose of |
|00002800| 74 68 69 73 20 64 69 73 | 63 75 73 73 69 6f 6e 2c |this dis|cussion,|
|00002810| 20 74 68 65 20 62 75 66 | 66 65 72 43 6d 64 2d 63 | the buf|ferCmd-c|
|00002820| 61 6c 6c 42 61 63 6b 43 | 6d 64 20 70 61 69 72 20 |allBackC|md pair |
|00002830| 63 61 6e 20 62 65 20 63 | 6f 6e 73 69 64 65 72 65 |can be c|onsidere|
|00002840| 64 20 61 20 75 6e 69 74 | 20 61 6e 64 20 77 69 6c |d a unit| and wil|
|00002850| 6c 20 62 65 20 72 65 66 | 65 72 72 65 64 20 74 6f |l be ref|erred to|
|00002860| 20 61 73 20 61 20 66 72 | 61 6d 65 20 66 72 6f 6d | as a fr|ame from|
|00002870| 20 68 65 72 65 20 6f 6e | 2e 20 53 69 6e 63 65 20 | here on|. Since |
|00002880| 69 74 d5 73 20 6f 66 74 | 65 6e 20 6e 6f 74 20 70 |it.s oft|en not p|
|00002890| 72 61 63 74 69 63 61 6c | 20 74 6f 20 70 6c 61 79 |ractical| to play|
|000028a0| 20 61 6e 20 65 6e 74 69 | 72 65 20 73 61 6d 70 6c | an enti|re sampl|
|000028b0| 65 20 69 6e 20 6f 6e 65 | 20 66 72 61 6d 65 2c 20 |e in one| frame, |
|000028c0| 79 6f 75 d5 6c 6c 20 70 | 72 6f 62 61 62 6c 79 20 |you.ll p|robably |
|000028d0| 6e 65 65 64 20 74 6f 20 | 62 72 65 61 6b 20 69 74 |need to |break it|
|000028e0| 20 75 70 20 69 6e 74 6f | 20 73 6d 61 6c 6c 65 72 | up into| smaller|
|000028f0| 20 70 69 65 63 65 73 20 | 61 6e 64 20 70 61 73 73 | pieces |and pass|
|00002900| 20 69 74 20 74 6f 20 74 | 68 65 20 53 6f 75 6e 64 | it to t|he Sound|
|00002910| 20 4d 61 6e 61 67 65 72 | 20 61 20 66 72 61 6d 65 | Manager| a frame|
|00002920| 20 61 74 20 61 20 74 69 | 6d 65 2e 20 46 69 67 75 | at a ti|me. Figu|
|00002930| 72 65 20 31 20 69 6c 6c | 75 73 74 72 61 74 65 73 |re 1 ill|ustrates|
|00002940| 20 68 6f 77 20 61 20 73 | 61 6d 70 6c 65 20 74 6f | how a s|ample to|
|00002950| 6f 20 6c 61 72 67 65 20 | 74 6f 20 66 69 74 20 69 |o large |to fit i|
|00002960| 6e 20 6d 65 6d 6f 72 79 | 20 69 73 20 62 72 6f 6b |n memory| is brok|
|00002970| 65 6e 20 75 70 20 69 6e | 74 6f 20 66 72 61 6d 65 |en up in|to frame|
|00002980| 73 20 63 6f 6e 73 69 73 | 74 69 6e 67 20 6f 66 20 |s consis|ting of |
|00002990| 61 20 62 75 66 66 65 72 | 43 6d 64 20 61 6e 64 20 |a buffer|Cmd and |
|000029a0| 63 61 6c 6c 42 61 63 6b | 43 6d 64 2e 0d 54 6f 20 |callBack|Cmd..To |
|000029b0| 66 75 72 74 68 65 72 20 | 72 65 69 6e 66 6f 72 63 |further |reinforc|
|000029c0| 65 20 74 68 65 20 69 6c | 6c 75 73 69 6f 6e 20 6f |e the il|lusion o|
|000029d0| 66 20 61 20 66 72 61 6d | 65 20 62 65 69 6e 67 20 |f a fram|e being |
|000029e0| 61 20 73 74 61 6e 64 61 | 6c 6f 6e 65 20 65 6e 74 |a standa|lone ent|
|000029f0| 69 74 79 2c 20 69 74 d5 | 73 20 75 73 65 66 75 6c |ity, it.|s useful|
|00002a00| 20 74 6f 20 65 6e 63 61 | 70 73 75 6c 61 74 65 20 | to enca|psulate |
|00002a10| 74 68 65 20 62 75 66 66 | 65 72 43 6d 64 2d 63 61 |the buff|erCmd-ca|
|00002a20| 6c 6c 42 61 63 6b 43 6d | 64 20 70 61 69 72 20 69 |llBackCm|d pair i|
|00002a30| 6e 20 61 20 72 6f 75 74 | 69 6e 65 2e 20 41 20 62 |n a rout|ine. A b|
|00002a40| 61 72 65 2d 62 6f 6e 65 | 73 20 76 65 72 73 69 6f |are-bone|s versio|
|00002a50| 6e 20 6f 66 20 61 20 51 | 75 65 75 65 46 72 61 6d |n of a Q|ueueFram|
|00002a60| 65 20 72 6f 75 74 69 6e | 65 20 6d 69 67 68 74 20 |e routin|e might |
|00002a70| 6c 6f 6f 6b 20 6c 69 6b | 65 20 74 68 69 73 3a 0d |look lik|e this:.|
|00002a80| 4f 53 45 72 72 20 51 75 | 65 75 65 46 72 61 6d 65 |OSErr Qu|eueFrame|
|00002a90| 20 28 53 6e 64 43 68 61 | 6e 6e 65 6c 50 74 72 20 | (SndCha|nnelPtr |
|00002aa0| 63 68 61 6e 2c 20 50 74 | 72 20 73 6e 64 44 61 74 |chan, Pt|r sndDat|
|00002ab0| 61 29 0d 7b 0d 09 4f 53 | 45 72 72 20 09 09 65 72 |a).{..OS|Err ..er|
|00002ac0| 72 3b 0d 09 53 6e 64 43 | 6f 6d 6d 61 6e 64 09 63 |r;..SndC|ommand.c|
|00002ad0| 6f 6d 6d 61 6e 64 3b 0d | 0d 09 63 6f 6d 6d 61 6e |ommand;.|..comman|
|00002ae0| 64 2e 63 6d 64 20 3d 20 | 62 75 66 66 65 72 43 6d |d.cmd = |bufferCm|
|00002af0| 64 3b 0d 09 63 6f 6d 6d | 61 6e 64 2e 70 61 72 61 |d;..comm|and.para|
|00002b00| 6d 31 20 3d 20 6e 69 6c | 3b 0d 09 63 6f 6d 6d 61 |m1 = nil|;..comma|
|00002b10| 6e 64 2e 70 61 72 61 6d | 32 20 3d 20 28 6c 6f 6e |nd.param|2 = (lon|
|00002b20| 67 29 20 73 6e 64 44 61 | 74 61 3b 0d 09 65 72 72 |g) sndDa|ta;..err|
|00002b30| 20 3d 20 53 6e 64 44 6f | 43 6f 6d 6d 61 6e 64 20 | = SndDo|Command |
|00002b40| 28 63 68 61 6e 2c 20 26 | 63 6f 6d 6d 61 6e 64 2c |(chan, &|command,|
|00002b50| 20 66 61 6c 73 65 29 3b | 0d 09 69 66 20 28 65 72 | false);|..if (er|
|00002b60| 72 29 0d 09 09 72 65 74 | 75 72 6e 20 65 72 72 3b |r)...ret|urn err;|
|00002b70| 0d 09 63 6f 6d 6d 61 6e | 64 2e 63 6d 64 20 3d 20 |..comman|d.cmd = |
|00002b80| 63 61 6c 6c 42 61 63 6b | 43 6d 64 3b 0d 09 63 6f |callBack|Cmd;..co|
|00002b90| 6d 6d 61 6e 64 2e 70 61 | 72 61 6d 31 20 3d 20 6e |mmand.pa|ram1 = n|
|00002ba0| 69 6c 3b 0d 09 63 6f 6d | 6d 61 6e 64 2e 70 61 72 |il;..com|mand.par|
|00002bb0| 61 6d 32 20 3d 20 6e 69 | 6c 3b 0d 09 65 72 72 20 |am2 = ni|l;..err |
|00002bc0| 3d 20 53 6e 64 44 6f 43 | 6f 6d 6d 61 6e 64 20 28 |= SndDoC|ommand (|
|00002bd0| 63 68 61 6e 2c 20 26 63 | 6f 6d 6d 61 6e 64 2c 20 |chan, &c|ommand, |
|00002be0| 66 61 6c 73 65 29 3b 0d | 09 69 66 20 28 65 72 72 |false);.|.if (err|
|00002bf0| 29 0d 09 09 72 65 74 75 | 72 6e 20 65 72 72 3b 0d |)...retu|rn err;.|
|00002c00| 7d 0d 42 79 20 71 75 65 | 75 69 6e 67 20 75 70 20 |}.By que|uing up |
|00002c10| 61 6e 6f 74 68 65 72 20 | 66 72 61 6d 65 20 66 72 |another |frame fr|
|00002c20| 6f 6d 20 74 68 65 20 63 | 61 6c 6c 62 61 63 6b 20 |om the c|allback |
|00002c30| 70 72 6f 63 65 64 75 72 | 65 2c 20 79 6f 75 20 63 |procedur|e, you c|
|00002c40| 61 6e 20 73 74 61 72 74 | 20 61 20 63 68 61 69 6e |an start| a chain|
|00002c50| 20 72 65 61 63 74 69 6f | 6e 20 74 68 61 74 20 77 | reactio|n that w|
|00002c60| 69 6c 6c 20 6b 65 65 70 | 20 74 68 65 20 73 61 6d |ill keep| the sam|
|00002c70| 70 6c 65 20 70 6c 61 79 | 69 6e 67 2e 20 42 65 20 |ple play|ing. Be |
|00002c80| 73 75 72 65 20 74 6f 20 | 68 61 76 65 20 61 6e 6f |sure to |have ano|
|00002c90| 74 68 65 72 20 66 72 61 | 6d 65 20 72 65 61 64 79 |ther fra|me ready|
|00002ca0| 20 61 6e 64 20 77 61 69 | 74 69 6e 67 20 62 65 66 | and wai|ting bef|
|00002cb0| 6f 72 65 20 74 68 65 20 | 53 6f 75 6e 64 20 4d 61 |ore the |Sound Ma|
|00002cc0| 6e 61 67 65 72 20 66 69 | 6e 69 73 68 65 73 20 70 |nager fi|nishes p|
|00002cd0| 6c 61 79 69 6e 67 20 74 | 68 65 20 63 75 72 72 65 |laying t|he curre|
|00002ce0| 6e 74 20 66 72 61 6d 65 | 2e 20 46 61 69 6c 75 72 |nt frame|. Failur|
|00002cf0| 65 20 74 6f 20 64 6f 20 | 74 68 69 73 20 77 69 6c |e to do |this wil|
|00002d00| 6c 20 63 61 75 73 65 20 | 61 20 67 61 70 20 69 6e |l cause |a gap in|
|00002d10| 20 74 68 65 20 70 6c 61 | 79 62 61 63 6b 20 6f 66 | the pla|yback of|
|00002d20| 20 74 68 65 20 73 6f 75 | 6e 64 2c 20 6f 66 74 65 | the sou|nd, ofte|
|00002d30| 6e 20 72 65 66 65 72 72 | 65 64 20 74 6f 20 61 73 |n referr|ed to as|
|00002d40| 20 6c 61 74 65 6e 63 79 | 2e 0d 54 77 6f 20 69 6d | latency|..Two im|
|00002d50| 70 6f 72 74 61 6e 74 20 | 66 61 63 74 6f 72 73 20 |portant |factors |
|00002d60| 74 68 61 74 20 63 61 6e | 20 63 61 75 73 65 20 6c |that can| cause l|
|00002d70| 61 74 65 6e 63 79 20 61 | 72 65 20 74 68 65 20 73 |atency a|re the s|
|00002d80| 70 65 65 64 20 6f 66 20 | 79 6f 75 72 20 73 6f 75 |peed of |your sou|
|00002d90| 72 63 65 20 6f 66 20 73 | 6f 75 6e 64 20 64 61 74 |rce of s|ound dat|
|00002da0| 61 20 61 6e 64 20 74 68 | 65 20 74 6f 74 61 6c 20 |a and th|e total |
|00002db0| 73 69 7a 65 20 6f 66 20 | 74 68 65 20 62 75 66 66 |size of |the buff|
|00002dc0| 65 72 73 20 79 6f 75 d5 | 72 65 20 75 73 69 6e 67 |ers you.|re using|
|00002dd0| 2e 20 54 68 65 20 66 61 | 73 74 65 72 20 79 6f 75 |. The fa|ster you|
|00002de0| 72 20 64 61 74 61 20 73 | 6f 75 72 63 65 2c 20 74 |r data s|ource, t|
|00002df0| 68 65 20 73 6d 61 6c 6c | 65 72 20 74 68 65 20 62 |he small|er the b|
|00002e00| 75 66 66 65 72 20 73 69 | 7a 65 20 79 6f 75 20 63 |uffer si|ze you c|
|00002e10| 61 6e 20 67 65 74 20 61 | 77 61 79 20 77 69 74 68 |an get a|way with|
|00002e20| 2c 20 77 68 69 6c 65 20 | 73 6c 6f 77 65 72 20 73 |, while |slower s|
|00002e30| 6f 75 72 63 65 73 20 72 | 65 71 75 69 72 65 20 6c |ources r|equire l|
|00002e40| 61 72 67 65 72 20 62 75 | 66 66 65 72 73 2e 20 46 |arger bu|ffers. F|
|00002e50| 6f 72 20 65 78 61 6d 70 | 6c 65 2c 20 69 66 20 79 |or examp|le, if y|
|00002e60| 6f 75 d5 72 65 20 72 65 | 61 64 69 6e 67 20 66 72 |ou.re re|ading fr|
|00002e70| 6f 6d 20 61 20 53 43 53 | 49 20 64 65 76 69 63 65 |om a SCS|I device|
|00002e80| 20 77 69 74 68 20 61 6e | 20 61 76 65 72 61 67 65 | with an| average|
|00002e90| 20 61 63 63 65 73 73 20 | 74 69 6d 65 20 6f 66 20 | access |time of |
|00002ea0| 31 35 20 6d 69 6c 6c 69 | 73 65 63 6f 6e 64 73 2c |15 milli|seconds,|
|00002eb0| 20 79 6f 75 20 63 61 6e | 20 6b 65 65 70 20 63 6f | you can| keep co|
|00002ec0| 6e 74 69 6e 75 6f 75 73 | 20 70 6c 61 79 62 61 63 |ntinuous| playbac|
|00002ed0| 6b 20 67 6f 69 6e 67 20 | 77 69 74 68 20 61 20 74 |k going |with a t|
|00002ee0| 6f 74 61 6c 20 6f 66 20 | 61 62 6f 75 74 20 31 30 |otal of |about 10|
|00002ef0| 4b 20 6f 66 20 62 75 66 | 66 65 72 20 73 70 61 63 |K of buf|fer spac|
|00002f00| 65 3b 20 69 66 20 79 6f | 75 72 20 73 6f 75 72 63 |e; if yo|ur sourc|
|00002f10| 65 20 69 73 20 4c 6f 63 | 61 6c 54 61 6c 6b 2c 20 |e is Loc|alTalk, |
|00002f20| 70 6c 61 6e 20 6f 6e 20 | 75 73 69 6e 67 20 73 69 |plan on |using si|
|00002f30| 67 6e 69 66 69 63 61 6e | 74 6c 79 20 6c 61 72 67 |gnifican|tly larg|
|00002f40| 65 72 20 62 75 66 66 65 | 72 73 2e 20 59 6f 75 20 |er buffe|rs. You |
|00002f50| 6d 61 79 20 6e 65 65 64 | 20 74 6f 20 65 78 70 65 |may need| to expe|
|00002f60| 72 69 6d 65 6e 74 20 74 | 6f 20 66 69 6e 64 20 74 |riment t|o find t|
|00002f70| 68 65 20 6f 70 74 69 6d | 61 6c 20 62 75 66 66 65 |he optim|al buffe|
|00002f80| 72 20 73 69 7a 65 2e 0d | 41 20 74 68 69 72 64 20 |r size..|A third |
|00002f90| 66 61 63 74 6f 72 20 74 | 68 61 74 20 63 61 6e 20 |factor t|hat can |
|00002fa0| 63 6f 6e 74 72 69 62 75 | 74 65 20 74 6f 20 6c 61 |contribu|te to la|
|00002fb0| 74 65 6e 63 79 20 69 73 | 20 74 68 65 20 73 70 65 |tency is| the spe|
|00002fc0| 65 64 20 61 74 20 77 68 | 69 63 68 20 79 6f 75 72 |ed at wh|ich your|
|00002fd0| 20 63 61 6c 6c 62 61 63 | 6b 20 63 6f 64 65 20 65 | callbac|k code e|
|00002fe0| 78 65 63 75 74 65 73 2e | 20 49 74 d5 73 20 76 65 |xecutes.| It.s ve|
|00002ff0| 72 79 20 69 6d 70 6f 72 | 74 61 6e 74 20 74 6f 20 |ry impor|tant to |
|00003000| 64 6f 20 61 73 20 6c 69 | 74 74 6c 65 20 77 6f 72 |do as li|ttle wor|
|00003010| 6b 20 61 73 20 70 6f 73 | 73 69 62 6c 65 20 77 69 |k as pos|sible wi|
|00003020| 74 68 69 6e 20 74 68 69 | 73 20 72 6f 75 74 69 6e |thin thi|s routin|
|00003030| 65 2c 20 61 6e 64 20 69 | 6e 20 65 78 74 72 65 6d |e, and i|n extrem|
|00003040| 65 20 63 61 73 65 73 20 | 69 74 20 6d 61 79 20 62 |e cases |it may b|
|00003050| 65 20 61 64 76 61 6e 74 | 61 67 65 6f 75 73 20 74 |e advant|ageous t|
|00003060| 6f 20 77 72 69 74 65 20 | 74 68 69 73 20 73 65 67 |o write |this seg|
|00003070| 6d 65 6e 74 20 6f 66 20 | 79 6f 75 72 20 63 6f 64 |ment of |your cod|
|00003080| 65 20 69 6e 20 61 73 73 | 65 6d 62 6c 79 20 6c 61 |e in ass|embly la|
|00003090| 6e 67 75 61 67 65 2e 20 | 4f 66 20 63 6f 75 72 73 |nguage. |Of cours|
|000030a0| 65 2c 20 66 61 73 74 65 | 72 20 36 38 30 30 30 2d |e, faste|r 68000-|
|000030b0| 66 61 6d 69 6c 79 20 6d | 61 63 68 69 6e 65 73 20 |family m|achines |
|000030c0| 77 69 6c 6c 20 6c 65 74 | 20 79 6f 75 20 67 65 74 |will let| you get|
|000030d0| 20 61 77 61 79 20 77 69 | 74 68 20 6d 6f 72 65 20 | away wi|th more |
|000030e0| 70 72 6f 63 65 73 73 69 | 6e 67 3b 20 61 20 72 6f |processi|ng; a ro|
|000030f0| 75 74 69 6e 65 20 74 68 | 61 74 20 6d 61 79 20 72 |utine th|at may r|
|00003100| 65 71 75 69 72 65 20 68 | 61 6e 64 20 63 6f 64 69 |equire h|and codi|
|00003110| 6e 67 20 74 6f 20 72 75 | 6e 20 6f 6e 20 61 20 4d |ng to ru|n on a M|
|00003120| 61 63 69 6e 74 6f 73 68 | 20 50 6c 75 73 20 63 61 |acintosh| Plus ca|
|00003130| 6e 20 70 72 6f 62 61 62 | 6c 79 20 62 65 20 77 68 |n probab|ly be wh|
|00003140| 69 70 70 65 64 20 6f 66 | 66 20 69 6e 20 71 75 69 |ipped of|f in qui|
|00003150| 63 6b 2d 61 6e 64 2d 64 | 69 72 74 79 20 43 20 6f |ck-and-d|irty C o|
|00003160| 6e 20 61 20 4d 61 63 69 | 6e 74 6f 73 68 20 51 75 |n a Maci|ntosh Qu|
|00003170| 61 64 72 61 2e 20 41 73 | 20 69 73 20 74 68 65 20 |adra. As| is the |
|00003180| 63 61 73 65 20 77 69 74 | 68 20 61 6c 6c 20 74 69 |case wit|h all ti|
|00003190| 6d 65 2d 63 72 69 74 69 | 63 61 6c 20 63 6f 64 65 |me-criti|cal code|
|000031a0| 20 6f 6e 20 74 68 65 20 | 4d 61 63 69 6e 74 6f 73 | on the |Macintos|
|000031b0| 68 2c 20 69 74 d5 73 20 | 69 6d 70 6f 72 74 61 6e |h, it.s |importan|
|000031c0| 74 20 74 6f 20 74 61 6b | 65 20 69 6e 74 6f 20 61 |t to tak|e into a|
|000031d0| 63 63 6f 75 6e 74 20 61 | 6c 6c 20 74 68 65 20 70 |ccount a|ll the p|
|000031e0| 6c 61 74 66 6f 72 6d 73 | 20 79 6f 75 72 20 63 6f |latforms| your co|
|000031f0| 64 65 20 6d 61 79 20 72 | 75 6e 20 6f 6e 2e 20 0d |de may r|un on. .|
|00003200| 4f 6e 63 65 20 79 6f 75 | d5 76 65 20 63 6f 6d 70 |Once you|.ve comp|
|00003210| 65 6e 73 61 74 65 64 20 | 66 6f 72 20 61 6e 79 20 |ensated |for any |
|00003220| 70 6f 74 65 6e 74 69 61 | 6c 20 6c 61 74 65 6e 63 |potentia|l latenc|
|00003230| 79 20 70 72 6f 62 6c 65 | 6d 73 2c 20 74 68 69 73 |y proble|ms, this|
|00003240| 20 6d 65 74 68 6f 64 20 | 6f 66 20 63 68 61 69 6e | method |of chain|
|00003250| 69 6e 67 20 63 6f 6d 70 | 6c 65 74 69 6f 6e 20 72 |ing comp|letion r|
|00003260| 6f 75 74 69 6e 65 73 20 | 68 61 73 20 61 20 63 6f |outines |has a co|
|00003270| 75 70 6c 65 20 6f 66 20 | 61 64 76 61 6e 74 61 67 |uple of |advantag|
|00003280| 65 73 3a 0d a5 09 41 66 | 74 65 72 20 79 6f 75 20 |es:...Af|ter you |
|00003290| 73 74 61 72 74 20 74 68 | 65 20 70 72 6f 63 65 73 |start th|e proces|
|000032a0| 73 20 62 79 20 71 75 65 | 75 69 6e 67 20 74 68 65 |s by que|uing the|
|000032b0| 20 66 69 72 73 74 20 66 | 72 61 6d 65 2c 20 74 68 | first f|rame, th|
|000032c0| 65 20 d2 72 65 61 63 74 | 69 6f 6e d3 20 69 73 20 |e .react|ion. is |
|000032d0| 73 65 6c 66 2d 73 75 73 | 74 61 69 6e 69 6e 67 3b |self-sus|taining;|
|000032e0| 20 69 74 20 77 69 6c 6c | 20 74 65 72 6d 69 6e 61 | it will| termina|
|000032f0| 74 65 20 65 69 74 68 65 | 72 20 77 68 65 6e 20 79 |te eithe|r when y|
|00003300| 6f 75 20 6b 69 6c 6c 20 | 69 74 20 6f 72 20 77 68 |ou kill |it or wh|
|00003310| 65 6e 20 69 74 20 72 75 | 6e 73 20 6f 75 74 20 6f |en it ru|ns out o|
|00003320| 66 20 64 61 74 61 2e 0d | a5 09 4f 6e 63 65 20 73 |f data..|..Once s|
|00003330| 74 61 72 74 65 64 2c 20 | 74 68 65 20 70 72 6f 63 |tarted, |the proc|
|00003340| 65 73 73 20 69 73 20 66 | 75 6c 6c 79 20 61 73 79 |ess is f|ully asy|
|00003350| 6e 63 68 72 6f 6e 6f 75 | 73 2e 20 54 68 69 73 20 |nchronou|s. This |
|00003360| 67 69 76 65 73 20 79 6f | 75 72 20 61 70 70 6c 69 |gives yo|ur appli|
|00003370| 63 61 74 69 6f 6e 20 74 | 68 65 20 61 62 69 6c 69 |cation t|he abili|
|00003380| 74 79 20 74 6f 20 63 6f | 6e 74 69 6e 75 65 20 77 |ty to co|ntinue w|
|00003390| 69 74 68 20 6f 74 68 65 | 72 20 74 61 73 6b 73 2e |ith othe|r tasks.|
|000033a0| 0d 0d 0d 46 69 67 75 72 | 65 20 31 0d 44 69 76 69 |...Figur|e 1.Divi|
|000033b0| 64 69 6e 67 20 61 20 53 | 61 6d 70 6c 65 20 69 6e |ding a S|ample in|
|000033c0| 74 6f 20 46 72 61 6d 65 | 73 0d 0d 59 6f 75 72 20 |to Frame|s..Your |
|000033d0| 63 61 6c 6c 62 61 63 6b | 20 70 72 6f 63 65 64 75 |callback| procedu|
|000033e0| 72 65 20 6d 75 73 74 20 | 74 61 6b 65 20 63 61 72 |re must |take car|
|000033f0| 65 20 6f 66 20 74 68 72 | 65 65 20 6d 61 6a 6f 72 |e of thr|ee major|
|00003400| 20 66 75 6e 63 74 69 6f | 6e 73 2e 20 49 74 20 6d | functio|ns. It m|
|00003410| 75 73 74 20 71 75 65 75 | 65 20 74 68 65 20 6e 65 |ust queu|e the ne|
|00003420| 78 74 20 66 72 61 6d 65 | 2c 20 72 65 66 69 6c 6c |xt frame|, refill|
|00003430| 20 74 68 65 20 62 75 66 | 66 65 72 20 74 68 61 74 | the buf|fer that|
|00003440| 20 77 61 73 20 6a 75 73 | 74 20 65 78 68 61 75 73 | was jus|t exhaus|
|00003450| 74 65 64 2c 20 61 6e 64 | 20 75 70 64 61 74 65 20 |ted, and| update |
|00003460| 74 68 65 20 62 75 66 66 | 65 72 20 69 6e 64 69 63 |the buff|er indic|
|00003470| 65 73 2e 20 49 6e 20 70 | 73 65 75 64 6f 63 6f 64 |es. In p|seudocod|
|00003480| 65 2c 20 74 68 65 20 70 | 72 6f 63 65 64 75 72 65 |e, the p|rocedure|
|00003490| 20 69 73 20 61 73 20 66 | 6f 6c 6c 6f 77 73 3a 0d | is as f|ollows:.|
|000034a0| 43 61 6c 6c 62 61 63 6b | 53 65 72 76 69 63 65 20 |Callback|Service |
|000034b0| 28 29 0d 7b 0d 09 2f 2f | 0d 09 2f 2f 09 09 50 6c |().{..//|..//..Pl|
|000034c0| 61 63 65 20 74 68 65 20 | 6e 65 78 74 20 66 75 6c |ace the |next ful|
|000034d0| 6c 20 62 75 66 66 65 72 | 20 69 6e 20 74 68 65 20 |l buffer| in the |
|000034e0| 71 75 65 75 65 2e 0d 09 | 2f 2f 0d 09 51 75 65 75 |queue...|//..Queu|
|000034f0| 65 46 72 61 6d 65 20 28 | 6f 75 72 43 68 61 6e 6e |eFrame (|ourChann|
|00003500| 65 6c 2c 20 66 75 6c 6c | 42 75 66 66 65 72 29 3b |el, full|Buffer);|
|00003510| 0d 09 2f 2f 0d 09 2f 2f | 09 09 52 65 66 69 6c 6c |..//..//|..Refill|
|00003520| 20 74 68 65 20 62 75 66 | 66 65 72 20 77 65 20 6a | the buf|fer we j|
|00003530| 75 73 74 20 66 69 6e 69 | 73 68 65 64 20 70 6c 61 |ust fini|shed pla|
|00003540| 79 69 6e 67 2e 0d 09 2f | 2f 0d 09 47 65 74 4d 6f |ying.../|/..GetMo|
|00003550| 72 65 44 61 74 61 20 28 | 65 6d 70 74 79 42 75 66 |reData (|emptyBuf|
|00003560| 66 65 72 29 3b 0d 09 2f | 2f 0d 09 2f 2f 09 09 46 |fer);../|/..//..F|
|00003570| 69 67 75 72 65 20 6f 75 | 74 20 77 68 61 74 20 74 |igure ou|t what t|
|00003580| 68 65 20 6e 65 78 74 20 | 73 65 74 20 6f 66 20 62 |he next |set of b|
|00003590| 75 66 66 65 72 73 20 77 | 69 6c 6c 20 62 65 2e 0d |uffers w|ill be..|
|000035a0| 09 2f 2f 0d 09 53 77 61 | 70 42 75 66 66 65 72 73 |.//..Swa|pBuffers|
|000035b0| 20 28 66 75 6c 6c 42 75 | 66 66 65 72 2c 20 65 6d | (fullBu|ffer, em|
|000035c0| 70 74 79 42 75 66 66 65 | 72 29 3b 0d 7d 0d 57 48 |ptyBuffe|r);.}.WH|
|000035d0| 41 54 20 4d 41 4b 45 53 | 20 4d 55 4c 54 49 42 55 |AT MAKES| MULTIBU|
|000035e0| 46 46 45 52 20 44 49 46 | 46 45 52 45 4e 54 3f 0d |FFER DIF|FERENT?.|
|000035f0| 54 68 65 20 70 72 65 76 | 69 6f 75 73 20 73 65 63 |The prev|ious sec|
|00003600| 74 69 6f 6e 20 64 69 73 | 63 75 73 73 65 64 20 67 |tion dis|cussed g|
|00003610| 65 6e 65 72 61 6c 20 74 | 61 63 74 69 63 73 20 66 |eneral t|actics f|
|00003620| 6f 72 20 6d 75 6c 74 69 | 70 6c 65 2d 62 75 66 66 |or multi|ple-buff|
|00003630| 65 72 69 6e 67 20 6d 6f | 64 65 6c 73 20 61 6e 64 |ering mo|dels and|
|00003640| 20 66 6f 72 20 63 68 61 | 69 6e 69 6e 67 20 63 61 | for cha|ining ca|
|00003650| 6c 6c 62 61 63 6b 20 72 | 6f 75 74 69 6e 65 73 3b |llback r|outines;|
|00003660| 20 74 68 65 73 65 20 77 | 6f 75 6c 64 20 62 65 20 | these w|ould be |
|00003670| 75 73 65 64 20 62 79 20 | 61 6e 79 20 63 6f 6e 74 |used by |any cont|
|00003680| 69 6e 75 6f 75 73 20 70 | 6c 61 79 20 6d 6f 64 75 |inuous p|lay modu|
|00003690| 6c 65 2e 20 4d 75 6c 74 | 69 42 75 66 66 65 72 2c |le. Mult|iBuffer,|
|000036a0| 20 69 6e 63 6c 75 64 65 | 64 20 6f 6e 20 74 68 65 | include|d on the|
|000036b0| 20 44 65 76 65 6c 6f 70 | 65 72 20 43 44 20 53 65 | Develop|er CD Se|
|000036c0| 72 69 65 73 20 64 69 73 | 63 2c 20 75 73 65 73 20 |ries dis|c, uses |
|000036d0| 74 68 65 73 65 20 62 61 | 73 69 63 20 63 6f 6e 63 |these ba|sic conc|
|000036e0| 65 70 74 73 20 61 73 20 | 69 74 73 20 66 6f 75 6e |epts as |its foun|
|000036f0| 64 61 74 69 6f 6e 2c 20 | 62 75 74 20 64 69 66 66 |dation, |but diff|
|00003700| 65 72 73 20 69 6e 20 73 | 65 76 65 72 61 6c 20 69 |ers in s|everal i|
|00003710| 6d 70 6f 72 74 61 6e 74 | 20 77 61 79 73 20 69 6e |mportant| ways in|
|00003720| 20 6f 72 64 65 72 20 74 | 6f 20 61 64 64 72 65 73 | order t|o addres|
|00003730| 73 20 73 6f 6d 65 20 70 | 65 72 66 6f 72 6d 61 6e |s some p|erforman|
|00003740| 63 65 20 69 73 73 75 65 | 73 20 61 6e 64 20 61 74 |ce issue|s and at|
|00003750| 74 61 69 6e 20 61 20 68 | 69 67 68 65 72 20 6c 65 |tain a h|igher le|
|00003760| 76 65 6c 20 6f 66 20 66 | 6c 65 78 69 62 69 6c 69 |vel of f|lexibili|
|00003770| 74 79 2e 0d 54 68 75 73 | 20 66 61 72 20 74 68 65 |ty..Thus| far the|
|00003780| 20 64 69 73 63 75 73 73 | 69 6f 6e 20 68 61 73 20 | discuss|ion has |
|00003790| 63 65 6e 74 65 72 65 64 | 20 6f 6e 20 70 6c 61 79 |centered| on play|
|000037a0| 62 61 63 6b 2d 64 72 69 | 76 65 6e 20 62 75 66 66 |back-dri|ven buff|
|000037b0| 65 72 69 6e 67 20 6d 6f | 64 65 6c 73 2c 20 69 6e |ering mo|dels, in|
|000037c0| 20 77 68 69 63 68 20 74 | 68 65 20 63 6f 6d 70 6c | which t|he compl|
|000037d0| 65 74 69 6f 6e 20 72 6f | 75 74 69 6e 65 20 69 73 |etion ro|utine is|
|000037e0| 20 6b 65 79 65 64 20 74 | 6f 20 74 68 65 20 70 6c | keyed t|o the pl|
|000037f0| 61 79 62 61 63 6b 2e 20 | 54 68 69 73 20 6d 6f 64 |ayback. |This mod|
|00003800| 65 6c 2c 20 6f 6e 20 77 | 68 69 63 68 20 4d 75 6c |el, on w|hich Mul|
|00003810| 74 69 42 75 66 66 65 72 | 20 69 73 20 62 61 73 65 |tiBuffer| is base|
|00003820| 64 2c 20 69 73 20 61 70 | 70 72 6f 70 72 69 61 74 |d, is ap|propriat|
|00003830| 65 20 66 6f 72 20 61 70 | 70 6c 69 63 61 74 69 6f |e for ap|plicatio|
|00003840| 6e 73 20 74 68 61 74 20 | 70 6c 61 79 20 66 72 6f |ns that |play fro|
|00003850| 6d 20 61 20 73 74 6f 72 | 61 67 65 20 64 65 76 69 |m a stor|age devi|
|00003860| 63 65 20 6f 72 20 74 68 | 61 74 20 70 6c 61 79 20 |ce or th|at play |
|00003870| 66 72 6f 6d 20 73 79 6e | 74 68 65 73 69 73 2e 20 |from syn|thesis. |
|00003880| 50 6c 61 79 69 6e 67 20 | 66 72 6f 6d 20 61 20 72 |Playing |from a r|
|00003890| 65 61 6c 2d 74 69 6d 65 | 20 73 6f 75 72 63 65 2c |eal-time| source,|
|000038a0| 20 73 75 63 68 20 61 73 | 20 61 20 73 6f 75 6e 64 | such as| a sound|
|000038b0| 20 69 6e 70 75 74 20 64 | 65 76 69 63 65 20 6f 72 | input d|evice or|
|000038c0| 20 61 20 64 61 74 61 20 | 73 74 72 65 61 6d 20 63 | a data |stream c|
|000038d0| 6f 6d 69 6e 67 20 6f 76 | 65 72 20 61 20 6e 65 74 |oming ov|er a net|
|000038e0| 77 6f 72 6b 2c 20 72 65 | 71 75 69 72 65 73 20 61 |work, re|quires a|
|000038f0| 20 73 6f 75 72 63 65 2d | 64 72 69 76 65 6e 20 62 | source-|driven b|
|00003900| 75 66 66 65 72 69 6e 67 | 20 6d 6f 64 65 6c 2c 20 |uffering| model, |
|00003910| 69 6e 20 77 68 69 63 68 | 20 74 68 65 20 63 61 6c |in which| the cal|
|00003920| 6c 62 61 63 6b 20 69 73 | 20 61 73 73 6f 63 69 61 |lback is| associa|
|00003930| 74 65 64 20 77 69 74 68 | 20 74 68 65 20 72 65 61 |ted with| the rea|
|00003940| 64 20 72 6f 75 74 69 6e | 65 2e 20 54 68 65 72 65 |d routin|e. There|
|00003950| d5 73 20 6c 69 74 74 6c | 65 20 64 69 66 66 65 72 |.s littl|e differ|
|00003960| 65 6e 63 65 20 62 65 74 | 77 65 65 6e 20 74 68 65 |ence bet|ween the|
|00003970| 73 65 20 74 77 6f 20 6d | 6f 64 65 6c 73 2c 20 62 |se two m|odels, b|
|00003980| 75 74 20 75 73 69 6e 67 | 20 74 68 65 20 77 72 6f |ut using| the wro|
|00003990| 6e 67 20 6d 6f 64 65 6c | 20 63 61 6e 20 6c 65 61 |ng model| can lea|
|000039a0| 64 20 74 6f 20 74 68 65 | 20 6c 6f 73 73 20 6f 66 |d to the| loss of|
|000039b0| 20 73 6d 61 6c 6c 20 61 | 6d 6f 75 6e 74 73 20 6f | small a|mounts o|
|000039c0| 66 20 73 6f 75 6e 64 20 | 64 61 74 61 2e 0d 54 68 |f sound |data..Th|
|000039d0| 65 20 6d 61 6a 6f 72 20 | 64 65 73 69 67 6e 20 67 |e major |design g|
|000039e0| 6f 61 6c 20 66 6f 72 20 | 4d 75 6c 74 69 42 75 66 |oal for |MultiBuf|
|000039f0| 66 65 72 20 77 61 73 20 | 74 6f 20 6d 61 6b 65 20 |fer was |to make |
|00003a00| 69 74 20 6d 6f 64 75 6c | 61 72 20 65 6e 6f 75 67 |it modul|ar enoug|
|00003a10| 68 20 74 6f 20 62 65 20 | 65 61 73 69 6c 79 20 63 |h to be |easily c|
|00003a20| 75 73 74 6f 6d 69 7a 65 | 64 2e 20 49 74 20 69 6e |ustomize|d. It in|
|00003a30| 63 6c 75 64 65 73 20 61 | 6e 20 69 6e 64 65 70 65 |cludes a|n indepe|
|00003a40| 6e 64 65 6e 74 20 70 72 | 6f 63 65 64 75 72 65 20 |ndent pr|ocedure |
|00003a50| 66 6f 72 20 72 65 61 64 | 69 6e 67 20 64 61 74 61 |for read|ing data|
|00003a60| 20 66 72 6f 6d 20 74 68 | 65 20 73 6f 75 72 63 65 | from th|e source|
|00003a70| 20 28 52 65 61 64 50 72 | 6f 63 29 2c 20 61 73 20 | (ReadPr|oc), as |
|00003a80| 77 65 6c 6c 20 61 73 20 | 61 20 70 72 6f 63 65 64 |well as |a proced|
|00003a90| 75 72 65 20 66 6f 72 20 | 70 72 6f 63 65 73 73 69 |ure for |processi|
|00003aa0| 6e 67 20 74 68 65 20 72 | 61 77 20 64 61 74 61 20 |ng the r|aw data |
|00003ab0| 6f 62 74 61 69 6e 65 64 | 20 66 72 6f 6d 20 74 68 |obtained| from th|
|00003ac0| 65 20 52 65 61 64 50 72 | 6f 63 20 28 50 72 6f 63 |e ReadPr|oc (Proc|
|00003ad0| 65 73 73 69 6e 67 50 72 | 6f 63 29 2e 20 4d 75 6c |essingPr|oc). Mul|
|00003ae0| 74 69 42 75 66 66 65 72 | 20 61 6c 73 6f 20 61 6c |tiBuffer| also al|
|00003af0| 6c 6f 77 73 20 79 6f 75 | 20 74 6f 20 77 6f 72 6b |lows you| to work|
|00003b00| 20 77 69 74 68 20 6d 6f | 72 65 20 74 68 61 6e 20 | with mo|re than |
|00003b10| 74 77 6f 20 62 75 66 66 | 65 72 73 3b 20 73 69 6d |two buff|ers; sim|
|00003b20| 70 6c 79 20 6d 6f 64 69 | 66 79 20 74 68 65 20 63 |ply modi|fy the c|
|00003b30| 6f 6e 73 74 61 6e 74 20 | 6b 4e 75 6d 42 75 66 66 |onstant |kNumBuff|
|00003b40| 65 72 73 2e 20 49 6e 20 | 73 6f 6d 65 20 73 69 74 |ers. In |some sit|
|00003b50| 75 61 74 69 6f 6e 73 2c | 20 6d 6f 72 65 20 74 68 |uations,| more th|
|00003b60| 61 6e 20 74 77 6f 20 62 | 75 66 66 65 72 73 20 63 |an two b|uffers c|
|00003b70| 61 6e 20 62 65 20 68 61 | 6e 64 79 2c 20 73 75 63 |an be ha|ndy, suc|
|00003b80| 68 20 61 73 20 69 6e 73 | 74 61 6e 63 65 73 20 77 |h as ins|tances w|
|00003b90| 68 65 72 65 20 79 6f 75 | 20 77 61 6e 74 20 74 6f |here you| want to|
|00003ba0| 20 72 65 64 75 63 65 20 | 74 68 65 20 6c 61 67 20 | reduce |the lag |
|00003bb0| 62 65 74 77 65 65 6e 20 | 70 6c 61 79 62 61 63 6b |between |playback|
|00003bc0| 20 74 69 6d 65 20 61 6e | 64 20 72 65 61 6c 20 74 | time an|d real t|
|00003bd0| 69 6d 65 2e 20 53 65 76 | 65 72 61 6c 20 63 6c 61 |ime. Sev|eral cla|
|00003be0| 73 73 65 73 20 6f 66 20 | 66 69 6c 74 65 72 20 72 |sses of |filter r|
|00003bf0| 65 71 75 69 72 65 20 74 | 68 61 74 20 79 6f 75 20 |equire t|hat you |
|00003c00| 68 61 76 65 20 61 20 66 | 61 69 72 6c 79 20 65 78 |have a f|airly ex|
|00003c10| 74 65 6e 73 69 76 65 20 | 73 65 74 20 6f 66 20 64 |tensive |set of d|
|00003c20| 61 74 61 20 61 76 61 69 | 6c 61 62 6c 65 20 66 6f |ata avai|lable fo|
|00003c30| 72 20 70 72 6f 63 65 73 | 73 69 6e 67 2e 20 50 75 |r proces|sing. Pu|
|00003c40| 6c 73 65 2d 72 65 73 70 | 6f 6e 73 65 20 66 69 6c |lse-resp|onse fil|
|00003c50| 74 65 72 73 2c 20 6c 6f | 77 2d 20 61 6e 64 20 68 |ters, lo|w- and h|
|00003c60| 69 67 68 2d 0d 70 61 73 | 73 20 28 66 69 72 73 74 |igh-.pas|s (first|
|00003c70| 2d 6f 72 64 65 72 29 20 | 66 69 6c 74 65 72 73 2c |-order) |filters,|
|00003c80| 20 61 6e 64 20 73 70 65 | 63 74 72 61 6c 2d 63 6f | and spe|ctral-co|
|00003c90| 6d 70 72 65 73 73 69 6f | 6e 20 66 69 6c 74 65 72 |mpressio|n filter|
|00003ca0| 73 20 61 72 65 20 61 6c | 6c 20 65 78 61 6d 70 6c |s are al|l exampl|
|00003cb0| 65 73 20 6f 66 20 61 70 | 70 6c 69 63 61 74 69 6f |es of ap|plicatio|
|00003cc0| 6e 73 20 69 6e 20 77 68 | 69 63 68 20 6d 75 6c 74 |ns in wh|ich mult|
|00003cd0| 69 70 6c 65 20 62 75 66 | 66 65 72 73 20 63 61 6e |iple buf|fers can|
|00003ce0| 20 73 69 6d 70 6c 69 66 | 79 20 69 6d 70 6c 65 6d | simplif|y implem|
|00003cf0| 65 6e 74 61 74 69 6f 6e | 2e 20 49 74 d5 73 20 69 |entation|. It.s i|
|00003d00| 6d 70 6f 72 74 61 6e 74 | 20 74 6f 20 72 65 61 6c |mportant| to real|
|00003d10| 69 7a 65 2c 20 68 6f 77 | 65 76 65 72 2c 20 74 68 |ize, how|ever, th|
|00003d20| 61 74 20 75 73 69 6e 67 | 20 6d 61 6e 79 20 62 75 |at using| many bu|
|00003d30| 66 66 65 72 73 20 69 6e | 74 72 6f 64 75 63 65 73 |ffers in|troduces|
|00003d40| 20 65 78 74 72 61 20 6f | 76 65 72 68 65 61 64 2c | extra o|verhead,|
|00003d50| 20 73 6f 20 79 6f 75 72 | 20 62 75 66 66 65 72 20 | so your| buffer |
|00003d60| 73 69 7a 65 73 20 77 69 | 6c 6c 20 6e 65 65 64 20 |sizes wi|ll need |
|00003d70| 74 6f 20 62 65 20 63 6f | 72 72 65 73 70 6f 6e 64 |to be co|rrespond|
|00003d80| 69 6e 67 6c 79 20 6c 61 | 72 67 65 72 2e 20 42 65 |ingly la|rger. Be|
|00003d90| 63 61 75 73 65 20 6f 66 | 20 74 68 69 73 20 61 64 |cause of| this ad|
|00003da0| 64 65 64 20 6f 76 65 72 | 68 65 61 64 2c 20 79 6f |ded over|head, yo|
|00003db0| 75 20 63 61 6e 20 65 6e | 64 20 75 70 20 69 6e 20 |u can en|d up in |
|00003dc0| 61 20 43 61 74 63 68 2d | 32 32 20 73 69 74 75 61 |a Catch-|22 situa|
|00003dd0| 74 69 6f 6e 3b 20 74 68 | 65 72 65 20 69 73 20 61 |tion; th|ere is a|
|00003de0| 20 70 6f 69 6e 74 20 61 | 74 20 77 68 69 63 68 20 | point a|t which |
|00003df0| 74 68 65 20 62 65 6e 65 | 66 69 74 20 6f 66 20 68 |the bene|fit of h|
|00003e00| 61 76 69 6e 67 20 6d 6f | 72 65 20 62 75 66 66 65 |aving mo|re buffe|
|00003e10| 72 73 20 69 73 20 6e 65 | 67 61 74 65 64 20 62 79 |rs is ne|gated by|
|00003e20| 20 74 68 65 20 69 6e 63 | 72 65 61 73 65 20 69 6e | the inc|rease in|
|00003e30| 20 62 75 66 66 65 72 20 | 73 69 7a 65 2e 0d 54 68 | buffer |size..Th|
|00003e40| 65 20 6f 70 74 69 6f 6e | 61 6c 20 70 72 6f 63 65 |e option|al proce|
|00003e50| 73 73 69 6e 67 20 70 72 | 6f 63 65 64 75 72 65 20 |ssing pr|ocedure |
|00003e60| 61 6c 6c 6f 77 73 20 79 | 6f 75 20 74 6f 20 70 65 |allows y|ou to pe|
|00003e70| 72 66 6f 72 6d 20 73 6f | 6d 65 20 73 69 6d 70 6c |rform so|me simpl|
|00003e80| 65 20 6d 6f 64 69 66 69 | 63 61 74 69 6f 6e 73 20 |e modifi|cations |
|00003e90| 6f 6e 20 74 68 65 20 64 | 61 74 61 20 62 65 66 6f |on the d|ata befo|
|00003ea0| 72 65 20 69 74 d5 73 20 | 70 6c 61 79 65 64 2e 20 |re it.s |played. |
|00003eb0| 49 74 d5 73 20 76 69 74 | 61 6c 20 74 68 61 74 20 |It.s vit|al that |
|00003ec0| 79 6f 75 20 6b 65 65 70 | 20 74 68 65 20 69 73 73 |you keep| the iss|
|00003ed0| 75 65 20 6f 66 20 6c 61 | 74 65 6e 63 79 20 69 6e |ue of la|tency in|
|00003ee0| 20 6d 69 6e 64 20 77 68 | 65 6e 20 64 65 61 6c 69 | mind wh|en deali|
|00003ef0| 6e 67 20 77 69 74 68 20 | 79 6f 75 72 20 70 72 6f |ng with |your pro|
|00003f00| 63 65 73 73 69 6e 67 20 | 70 72 6f 63 65 64 75 72 |cessing |procedur|
|00003f10| 65 3b 20 69 74 20 63 61 | 6e 20 68 61 76 65 20 61 |e; it ca|n have a|
|00003f20| 20 70 72 6f 66 6f 75 6e | 64 20 65 66 66 65 63 74 | profoun|d effect|
|00003f30| 20 6f 6e 20 74 68 65 20 | 61 6d 6f 75 6e 74 20 6f | on the |amount o|
|00003f40| 66 20 74 69 6d 65 20 72 | 65 71 75 69 72 65 64 20 |f time r|equired |
|00003f50| 74 6f 20 72 65 61 64 79 | 20 61 20 62 75 66 66 65 |to ready| a buffe|
|00003f60| 72 20 66 6f 72 20 70 6c | 61 79 2e 20 53 69 6e 63 |r for pl|ay. Sinc|
|00003f70| 65 20 74 68 69 73 20 69 | 73 20 61 20 74 69 6d 65 |e this i|s a time|
|00003f80| 2d 63 72 69 74 69 63 61 | 6c 20 73 65 63 74 69 6f |-critica|l sectio|
|00003f90| 6e 20 6f 66 20 74 68 65 | 20 62 75 66 66 65 72 69 |n of the| bufferi|
|00003fa0| 6e 67 20 63 6f 64 65 2c | 20 69 74 d5 73 20 6f 66 |ng code,| it.s of|
|00003fb0| 74 65 6e 20 64 65 73 69 | 72 61 62 6c 65 20 74 6f |ten desi|rable to|
|00003fc0| 20 77 72 69 74 65 20 74 | 68 69 73 20 70 72 6f 63 | write t|his proc|
|00003fd0| 65 64 75 72 65 20 69 6e | 20 61 73 73 65 6d 62 6c |edure in| assembl|
|00003fe0| 79 20 6c 61 6e 67 75 61 | 67 65 20 74 6f 20 73 71 |y langua|ge to sq|
|00003ff0| 75 65 65 7a 65 20 6f 75 | 74 20 74 68 65 20 68 69 |ueeze ou|t the hi|
|00004000| 67 68 65 73 74 20 70 65 | 72 66 6f 72 6d 61 6e 63 |ghest pe|rformanc|
|00004010| 65 20 70 6f 73 73 69 62 | 6c 65 2e 0d 42 65 63 61 |e possib|le..Beca|
|00004020| 75 73 65 20 74 68 65 20 | 70 72 6f 63 65 64 75 72 |use the |procedur|
|00004030| 65 73 20 66 6f 72 20 72 | 65 61 64 69 6e 67 20 73 |es for r|eading s|
|00004040| 6f 75 6e 64 20 64 61 74 | 61 20 61 6e 64 20 66 6f |ound dat|a and fo|
|00004050| 72 20 70 72 6f 63 65 73 | 73 69 6e 67 20 74 68 65 |r proces|sing the|
|00004060| 20 64 61 74 61 20 61 72 | 65 20 73 65 70 61 72 61 | data ar|e separa|
|00004070| 74 65 20 6d 6f 64 75 6c | 65 73 2c 20 4d 75 6c 74 |te modul|es, Mult|
|00004080| 69 42 75 66 66 65 72 20 | 69 73 20 71 75 69 74 65 |iBuffer |is quite|
|00004090| 20 66 6c 65 78 69 62 6c | 65 2e 20 54 68 65 20 70 | flexibl|e. The p|
|000040a0| 72 6f 67 72 61 6d 20 69 | 6e 63 6c 75 64 65 73 20 |rogram i|ncludes |
|000040b0| 61 20 73 69 6d 70 6c 65 | 20 65 78 61 6d 70 6c 65 |a simple| example|
|000040c0| 20 6f 66 20 74 68 69 73 | 20 66 6c 65 78 69 62 69 | of this| flexibi|
|000040d0| 6c 69 74 79 2e 20 4f 6e | 65 20 6f 66 20 74 68 65 |lity. On|e of the|
|000040e0| 20 70 6c 61 79 62 61 63 | 6b 20 6f 70 74 69 6f 6e | playbac|k option|
|000040f0| 73 20 69 73 20 74 6f 20 | 70 6c 61 79 20 61 6e 20 |s is to |play an |
|00004100| 41 75 64 69 6f 20 49 6e | 74 65 72 63 68 61 6e 67 |Audio In|terchang|
|00004110| 65 20 46 69 6c 65 20 46 | 6f 72 6d 61 74 20 28 41 |e File F|ormat (A|
|00004120| 49 46 46 29 20 66 69 6c | 65 20 62 61 63 6b 77 61 |IFF) fil|e backwa|
|00004130| 72 64 2e 20 54 6f 20 61 | 63 68 69 65 76 65 20 74 |rd. To a|chieve t|
|00004140| 68 69 73 2c 20 49 20 61 | 6c 74 65 72 65 64 20 52 |his, I a|ltered R|
|00004150| 65 61 64 50 72 6f 63 20 | 74 6f 20 72 65 61 64 20 |eadProc |to read |
|00004160| 63 68 75 6e 6b 73 20 6f | 66 20 74 68 65 20 74 61 |chunks o|f the ta|
|00004170| 72 67 65 74 20 66 69 6c | 65 20 66 72 6f 6d 20 65 |rget fil|e from e|
|00004180| 6e 64 20 74 6f 20 62 65 | 67 69 6e 6e 69 6e 67 2c |nd to be|ginning,|
|00004190| 20 74 68 65 6e 20 75 73 | 65 64 20 50 72 6f 63 65 | then us|ed Proce|
|000041a0| 73 73 69 6e 67 50 72 6f | 63 20 74 6f 20 72 65 76 |ssingPro|c to rev|
|000041b0| 65 72 73 65 20 74 68 65 | 20 63 6f 6e 74 65 6e 74 |erse the| content|
|000041c0| 73 20 6f 66 20 74 68 65 | 20 62 75 66 66 65 72 2e |s of the| buffer.|
|000041d0| 20 49 66 20 79 6f 75 20 | 74 61 6b 65 20 61 20 6c | If you |take a l|
|000041e0| 6f 6f 6b 20 69 6e 20 50 | 6c 61 79 46 72 6f 6d 46 |ook in P|layFromF|
|000041f0| 69 6c 65 2e 63 2c 20 79 | 6f 75 d5 6c 6c 20 66 69 |ile.c, y|ou.ll fi|
|00004200| 6e 64 20 74 68 61 74 20 | 74 68 65 20 64 69 66 66 |nd that |the diff|
|00004210| 65 72 65 6e 63 65 73 20 | 62 65 74 77 65 65 6e 20 |erences |between |
|00004220| 74 68 65 20 66 75 6e 63 | 74 69 6f 6e 73 20 52 65 |the func|tions Re|
|00004230| 61 64 50 72 6f 63 20 61 | 6e 64 20 50 72 6f 63 65 |adProc a|nd Proce|
|00004240| 73 73 69 6e 67 50 72 6f | 63 20 61 6e 64 20 74 68 |ssingPro|c and th|
|00004250| 65 69 72 20 63 6f 75 6e | 74 65 72 70 61 72 74 73 |eir coun|terparts|
|00004260| 20 42 61 63 6b 52 65 61 | 64 50 72 6f 63 20 61 6e | BackRea|dProc an|
|00004270| 64 20 42 61 63 6b 50 72 | 6f 63 65 73 73 69 6e 67 |d BackPr|ocessing|
|00004280| 50 72 6f 63 20 61 72 65 | 20 6d 69 6e 69 6d 61 6c |Proc are| minimal|
|00004290| 2e 0d 48 4f 57 20 49 54 | 20 48 41 4e 47 53 20 54 |..HOW IT| HANGS T|
|000042a0| 4f 47 45 54 48 45 52 0d | 4d 75 6c 74 69 42 75 66 |OGETHER.|MultiBuf|
|000042b0| 66 65 72 20 69 73 20 62 | 61 73 69 63 61 6c 6c 79 |fer is b|asically|
|000042c0| 20 61 20 73 65 72 69 65 | 73 20 6f 66 20 74 68 72 | a serie|s of thr|
|000042d0| 65 65 20 73 65 71 75 65 | 6e 74 69 61 6c 6c 79 20 |ee seque|ntially |
|000042e0| 63 68 61 69 6e 65 64 20 | 69 6e 74 65 72 72 75 70 |chained |interrup|
|000042f0| 74 20 72 6f 75 74 69 6e | 65 73 2e 20 54 68 65 73 |t routin|es. Thes|
|00004300| 65 20 61 72 65 20 74 68 | 65 20 63 61 6c 6c 42 61 |e are th|e callBa|
|00004310| 63 6b 50 72 6f 63 2c 20 | 61 20 72 65 61 64 20 63 |ckProc, |a read c|
|00004320| 6f 6d 70 6c 65 74 69 6f | 6e 20 72 6f 75 74 69 6e |ompletio|n routin|
|00004330| 65 2c 20 61 6e 64 20 61 | 20 64 65 66 65 72 72 65 |e, and a| deferre|
|00004340| 64 20 74 61 73 6b 20 74 | 68 61 74 20 74 61 6b 65 |d task t|hat take|
|00004350| 73 20 63 61 72 65 20 6f | 66 20 61 6e 79 20 70 72 |s care o|f any pr|
|00004360| 6f 63 65 73 73 69 6e 67 | 20 74 68 61 74 20 6e 65 |ocessing| that ne|
|00004370| 65 64 73 20 74 6f 20 62 | 65 20 64 6f 6e 65 20 6f |eds to b|e done o|
|00004380| 6e 20 74 68 65 20 72 61 | 77 20 64 61 74 61 2e 20 |n the ra|w data. |
|00004390| 44 65 66 65 72 72 65 64 | 20 74 61 73 6b 73 20 61 |Deferred| tasks a|
|000043a0| 72 65 20 65 73 73 65 6e | 74 69 61 6c 6c 79 20 69 |re essen|tially i|
|000043b0| 6e 74 65 72 72 75 70 74 | 20 72 6f 75 74 69 6e 65 |nterrupt| routine|
|000043c0| 73 20 74 68 61 74 20 67 | 65 74 20 70 75 74 20 6f |s that g|et put o|
|000043d0| 66 66 20 75 6e 74 69 6c | 20 74 68 65 20 72 65 73 |ff until| the res|
|000043e0| 74 20 6f 66 20 74 68 65 | 20 72 65 67 75 6c 61 72 |t of the| regular|
|000043f0| 6c 79 20 73 63 68 65 64 | 75 6c 65 64 20 69 6e 74 |ly sched|uled int|
|00004400| 65 72 72 75 70 74 73 20 | 68 61 76 65 20 63 6f 6d |errupts |have com|
|00004410| 70 6c 65 74 65 64 2e 20 | 41 20 64 65 66 65 72 72 |pleted. |A deferr|
|00004420| 65 64 20 74 61 73 6b 20 | 77 6f 6e d5 74 20 d2 73 |ed task |won.t .s|
|00004430| 74 61 72 76 65 d3 20 69 | 6d 70 6f 72 74 61 6e 74 |tarve. i|mportant|
|00004440| 20 69 6e 74 65 72 72 75 | 70 74 73 20 65 78 65 63 | interru|pts exec|
|00004450| 75 74 69 6e 67 20 61 74 | 20 61 20 6c 6f 77 65 72 |uting at| a lower|
|00004460| 20 70 72 69 6f 72 69 74 | 79 20 6c 65 76 65 6c 2e | priorit|y level.|
|00004470| 20 53 75 63 68 20 74 61 | 73 6b 73 20 61 6c 73 6f | Such ta|sks also|
|00004480| 20 68 61 76 65 20 74 68 | 65 20 61 64 76 61 6e 74 | have th|e advant|
|00004490| 61 67 65 20 6f 66 20 65 | 78 65 63 75 74 69 6e 67 |age of e|xecuting|
|000044a0| 20 77 68 65 6e 20 69 6e | 74 65 72 72 75 70 74 73 | when in|terrupts|
|000044b0| 20 68 61 76 65 20 62 65 | 65 6e 20 72 65 65 6e 61 | have be|en reena|
|000044c0| 62 6c 65 64 2c 20 61 6c | 6c 6f 77 69 6e 67 20 72 |bled, al|lowing r|
|000044d0| 65 67 75 6c 61 72 20 69 | 6e 74 65 72 72 75 70 74 |egular i|nterrupt|
|000044e0| 20 70 72 6f 63 65 73 73 | 69 6e 67 20 74 6f 20 63 | process|ing to c|
|000044f0| 6f 6e 74 69 6e 75 65 20 | 64 75 72 69 6e 67 20 74 |ontinue |during t|
|00004500| 68 65 69 72 20 65 78 65 | 63 75 74 69 6f 6e 2e 20 |heir exe|cution. |
|00004510| 55 6e 66 6f 72 74 75 6e | 61 74 65 6c 79 2c 20 61 |Unfortun|ately, a|
|00004520| 20 64 65 66 65 72 72 65 | 64 20 74 61 73 6b 20 69 | deferre|d task i|
|00004530| 73 20 73 74 69 6c 6c 20 | 62 6f 75 6e 64 20 62 79 |s still |bound by|
|00004540| 20 74 68 65 20 72 65 73 | 74 72 69 63 74 69 6f 6e | the res|triction|
|00004550| 73 20 6f 6e 20 6d 6f 76 | 69 6e 67 20 6f 72 20 70 |s on mov|ing or p|
|00004560| 75 72 67 69 6e 67 20 6d | 65 6d 6f 72 79 20 70 6c |urging m|emory pl|
|00004570| 61 63 65 64 20 6f 6e 20 | 72 65 67 75 6c 61 72 20 |aced on |regular |
|00004580| 69 6e 74 65 72 72 75 70 | 74 20 72 6f 75 74 69 6e |interrup|t routin|
|00004590| 65 73 2e 0d 54 68 65 20 | 72 6f 75 74 69 6e 65 20 |es..The |routine |
|000045a0| 44 6f 75 62 6c 65 42 75 | 66 66 65 72 20 62 65 67 |DoubleBu|ffer beg|
|000045b0| 69 6e 73 20 74 68 65 20 | 65 78 65 63 75 74 69 6f |ins the |executio|
|000045c0| 6e 2e 20 49 74 20 74 61 | 6b 65 73 20 63 61 72 65 |n. It ta|kes care|
|000045d0| 20 6f 66 20 73 65 74 74 | 69 6e 67 20 75 70 20 70 | of sett|ing up p|
|000045e0| 72 69 76 61 74 65 20 76 | 61 72 69 61 62 6c 65 73 |rivate v|ariables|
|000045f0| 2c 20 70 72 69 6d 69 6e | 67 20 74 68 65 20 62 75 |, primin|g the bu|
|00004600| 66 66 65 72 73 2c 20 61 | 6e 64 20 69 6e 69 74 69 |ffers, a|nd initi|
|00004610| 61 74 69 6e 67 20 74 68 | 65 20 70 6c 61 79 20 74 |ating th|e play t|
|00004620| 68 61 74 20 73 74 61 72 | 74 73 20 74 68 65 20 63 |hat star|ts the c|
|00004630| 68 61 69 6e 20 72 65 61 | 63 74 69 6f 6e 2e 0d 4d |hain rea|ction..M|
|00004640| 75 6c 74 69 42 75 66 66 | 65 72 20 69 73 20 63 6f |ultiBuff|er is co|
|00004650| 6d 70 6f 73 65 64 20 6f | 66 20 73 69 78 20 6d 61 |mposed o|f six ma|
|00004660| 69 6e 20 66 69 6c 65 73 | 2c 20 65 61 63 68 20 6f |in files|, each o|
|00004670| 66 20 77 68 69 63 68 20 | 64 65 61 6c 73 20 77 69 |f which |deals wi|
|00004680| 74 68 20 6f 6e 65 20 6f | 66 20 74 68 65 20 66 75 |th one o|f the fu|
|00004690| 6e 63 74 69 6f 6e 61 6c | 20 61 73 70 65 63 74 73 |nctional| aspects|
|000046a0| 20 6f 66 20 4d 75 6c 74 | 69 42 75 66 66 65 72 2e | of Mult|iBuffer.|
|000046b0| 0d a5 09 4d 61 69 6e 41 | 70 70 2e 63 20 63 6f 6e |...MainA|pp.c con|
|000046c0| 74 61 69 6e 73 20 74 68 | 65 20 61 70 70 6c 69 63 |tains th|e applic|
|000046d0| 61 74 69 6f 6e 20 66 72 | 61 6d 65 77 6f 72 6b 20 |ation fr|amework |
|000046e0| 66 6f 72 20 74 68 65 20 | 4d 75 6c 74 69 42 75 66 |for the |MultiBuf|
|000046f0| 66 65 72 20 64 65 6d 6f | 2e 20 0d a5 09 44 6f 75 |fer demo|. ...Dou|
|00004700| 62 6c 65 42 75 66 66 65 | 72 73 2e 63 20 69 6e 63 |bleBuffe|rs.c inc|
|00004710| 6c 75 64 65 73 20 61 6c | 6c 20 74 68 65 20 63 6f |ludes al|l the co|
|00004720| 64 65 20 66 6f 72 20 64 | 65 61 6c 69 6e 67 20 77 |de for d|ealing w|
|00004730| 69 74 68 20 6d 75 6c 74 | 69 62 75 66 66 65 72 69 |ith mult|ibufferi|
|00004740| 6e 67 2e 20 46 6f 72 20 | 6d 6f 73 74 20 61 70 70 |ng. For |most app|
|00004750| 6c 69 63 61 74 69 6f 6e | 73 2c 20 79 6f 75 20 73 |lication|s, you s|
|00004760| 68 6f 75 6c 64 6e d5 74 | 20 6e 65 65 64 20 74 6f |houldn.t| need to|
|00004770| 20 6d 6f 64 69 66 79 20 | 61 6e 79 20 6f 66 20 74 | modify |any of t|
|00004780| 68 65 20 63 6f 64 65 20 | 69 6e 20 74 68 69 73 20 |he code |in this |
|00004790| 66 69 6c 65 2e 20 0d 0d | a5 09 41 49 46 46 47 6f |file. ..|..AIFFGo|
|000047a0| 6f 64 69 65 73 2e 63 20 | 66 65 61 74 75 72 65 73 |odies.c |features|
|000047b0| 20 66 75 6e 20 77 69 74 | 68 20 70 61 72 73 69 6e | fun wit|h parsin|
|000047c0| 67 20 41 49 46 46 20 68 | 65 61 64 65 72 20 69 6e |g AIFF h|eader in|
|000047d0| 66 6f 72 6d 61 74 69 6f | 6e 2e 20 54 68 65 20 62 |formatio|n. The b|
|000047e0| 61 73 69 63 20 70 75 72 | 70 6f 73 65 20 6f 66 20 |asic pur|pose of |
|000047f0| 74 68 65 20 63 6f 64 65 | 20 69 6e 20 74 68 69 73 |the code| in this|
|00004800| 20 66 69 6c 65 20 69 73 | 20 74 6f 20 67 65 74 20 | file is| to get |
|00004810| 70 65 72 74 69 6e 65 6e | 74 20 69 6e 66 6f 72 6d |pertinen|t inform|
|00004820| 61 74 69 6f 6e 20 6f 75 | 74 20 6f 66 20 61 6e 20 |ation ou|t of an |
|00004830| 41 49 46 46 20 66 69 6c | 65 20 61 6e 64 20 69 6e |AIFF fil|e and in|
|00004840| 74 6f 20 61 20 73 6f 75 | 6e 64 20 68 65 61 64 65 |to a sou|nd heade|
|00004850| 72 2e 0d a5 09 50 6c 61 | 79 46 72 6f 6d 46 69 6c |r....Pla|yFromFil|
|00004860| 65 2e 63 20 63 6f 6e 74 | 61 69 6e 73 20 74 68 65 |e.c cont|ains the|
|00004870| 20 72 6f 75 74 69 6e 65 | 73 20 66 6f 72 20 70 6c | routine|s for pl|
|00004880| 61 79 69 6e 67 20 61 6e | 20 41 49 46 46 20 66 69 |aying an| AIFF fi|
|00004890| 6c 65 20 66 6f 72 77 61 | 72 64 20 61 6e 64 20 62 |le forwa|rd and b|
|000048a0| 61 63 6b 77 61 72 64 2e | 0d a5 09 50 6c 61 79 46 |ackward.|...PlayF|
|000048b0| 72 6f 6d 53 79 6e 74 68 | 2e 63 20 68 61 73 20 74 |romSynth|.c has t|
|000048c0| 68 65 20 63 6f 64 65 20 | 6e 65 63 65 73 73 61 72 |he code |necessar|
|000048d0| 79 20 66 6f 72 20 70 6c | 61 79 69 6e 67 20 61 20 |y for pl|aying a |
|000048e0| 77 61 76 65 20 73 65 67 | 6d 65 6e 74 20 61 73 20 |wave seg|ment as |
|000048f0| 61 20 63 6f 6e 74 69 6e | 75 6f 75 73 20 73 6f 75 |a contin|uous sou|
|00004900| 6e 64 2e 0d a5 09 4f 73 | 63 69 6c 6c 61 74 6f 72 |nd....Os|cillator|
|00004910| 2e 63 20 69 73 20 72 65 | 73 70 6f 6e 73 69 62 6c |.c is re|sponsibl|
|00004920| 65 20 66 6f 72 20 67 65 | 6e 65 72 61 74 69 6e 67 |e for ge|nerating|
|00004930| 20 6f 6e 65 20 63 79 63 | 6c 65 20 6f 66 20 61 20 | one cyc|le of a |
|00004940| 73 69 6e 65 20 77 61 76 | 65 20 61 74 20 61 20 73 |sine wav|e at a s|
|00004950| 70 65 63 69 66 69 65 64 | 20 66 72 65 71 75 65 6e |pecified| frequen|
|00004960| 63 79 20 61 6e 64 20 61 | 6d 70 6c 69 74 75 64 65 |cy and a|mplitude|
|00004970| 2e 0d 4e 55 54 53 20 41 | 4e 44 20 42 4f 4c 54 53 |..NUTS A|ND BOLTS|
|00004980| 0d 54 68 65 20 72 65 73 | 74 20 6f 66 20 74 68 69 |.The res|t of thi|
|00004990| 73 20 61 72 74 69 63 6c | 65 20 67 6f 65 73 20 69 |s articl|e goes i|
|000049a0| 6e 74 6f 20 67 6f 72 79 | 20 64 65 74 61 69 6c 20 |nto gory| detail |
|000049b0| 6f 6e 20 74 68 65 20 69 | 6e 6e 65 72 20 77 6f 72 |on the i|nner wor|
|000049c0| 6b 69 6e 67 73 20 6f 66 | 20 4d 75 6c 74 69 42 75 |kings of| MultiBu|
|000049d0| 66 66 65 72 2e 20 59 6f | 75 d5 6c 6c 20 66 69 6e |ffer. Yo|u.ll fin|
|000049e0| 64 20 74 68 69 73 20 68 | 65 6c 70 66 75 6c 20 69 |d this h|elpful i|
|000049f0| 66 20 79 6f 75 20 70 6c | 61 6e 20 6f 6e 20 6d 6f |f you pl|an on mo|
|00004a00| 64 69 66 79 69 6e 67 20 | 74 68 65 20 63 6f 64 65 |difying |the code|
|00004a10| 20 74 6f 20 73 75 69 74 | 20 79 6f 75 72 20 6f 77 | to suit| your ow|
|00004a20| 6e 20 6e 65 65 64 73 2c | 20 6f 72 20 69 66 20 79 |n needs,| or if y|
|00004a30| 6f 75 20 77 61 6e 74 20 | 74 6f 20 67 61 69 6e 20 |ou want |to gain |
|00004a40| 61 20 70 61 69 6e 66 75 | 6c 6c 79 20 69 6e 2d 64 |a painfu|lly in-d|
|00004a50| 65 70 74 68 20 75 6e 64 | 65 72 73 74 61 6e 64 69 |epth und|erstandi|
|00004a60| 6e 67 20 6f 66 20 74 68 | 65 20 70 72 6f 63 65 73 |ng of th|e proces|
|00004a70| 73 65 73 20 69 6e 76 6f | 6c 76 65 64 2e 0d 43 4f |ses invo|lved..CO|
|00004a80| 4e 53 54 41 4e 54 53 0d | 54 68 65 72 65 20 61 72 |NSTANTS.|There ar|
|00004a90| 65 20 6f 6e 6c 79 20 74 | 77 6f 20 63 6f 6e 73 74 |e only t|wo const|
|00004aa0| 61 6e 74 73 20 79 6f 75 | 20 6e 65 65 64 20 74 6f |ants you| need to|
|00004ab0| 20 77 6f 72 72 79 20 61 | 62 6f 75 74 2e 0d 6b 42 | worry a|bout..kB|
|00004ac0| 75 66 66 65 72 53 69 7a | 65 2e 20 54 68 69 73 20 |ufferSiz|e. This |
|00004ad0| 69 6e 64 69 63 61 74 65 | 73 20 74 68 65 20 73 69 |indicate|s the si|
|00004ae0| 7a 65 20 6f 66 20 74 68 | 65 20 62 75 66 66 65 72 |ze of th|e buffer|
|00004af0| 20 69 6e 20 62 79 74 65 | 73 2e 20 54 68 65 20 6c | in byte|s. The l|
|00004b00| 61 72 67 65 72 20 74 68 | 69 73 20 76 61 6c 75 65 |arger th|is value|
|00004b10| 2c 20 74 68 65 20 6d 6f | 72 65 20 74 69 6d 65 20 |, the mo|re time |
|00004b20| 79 6f 75 20 68 61 76 65 | 20 62 65 74 77 65 65 6e |you have| between|
|00004b30| 20 62 75 66 66 65 72 20 | 73 77 69 74 63 68 65 73 | buffer |switches|
|00004b40| 2e 20 49 74 20 73 68 6f | 75 6c 64 20 62 65 20 61 |. It sho|uld be a|
|00004b50| 20 6d 75 6c 74 69 70 6c | 65 20 6f 66 20 35 31 32 | multipl|e of 512|
|00004b60| 2e 0d 6b 4e 75 6d 42 75 | 66 66 65 72 73 2e 20 54 |..kNumBu|ffers. T|
|00004b70| 68 65 20 76 61 6c 75 65 | 20 6f 66 20 74 68 69 73 |he value| of this|
|00004b80| 20 63 6f 6e 73 74 61 6e | 74 20 64 65 74 65 72 6d | constan|t determ|
|00004b90| 69 6e 65 73 20 74 68 65 | 20 6e 75 6d 62 65 72 20 |ines the| number |
|00004ba0| 6f 66 20 62 75 66 66 65 | 72 73 20 74 68 61 74 20 |of buffe|rs that |
|00004bb0| 4d 75 6c 74 69 42 75 66 | 66 65 72 20 75 73 65 73 |MultiBuf|fer uses|
|00004bc0| 2e 20 49 6e 20 6d 6f 73 | 74 20 63 61 73 65 73 2c |. In mos|t cases,|
|00004bd0| 20 74 68 69 73 20 76 61 | 6c 75 65 20 73 68 6f 75 | this va|lue shou|
|00004be0| 6c 64 20 62 65 20 32 2e | 0d 49 4d 50 4f 52 54 41 |ld be 2.|.IMPORTA|
|00004bf0| 4e 54 20 44 41 54 41 20 | 53 54 52 55 43 54 55 52 |NT DATA |STRUCTUR|
|00004c00| 45 53 0d 4c 69 73 74 65 | 64 20 68 65 72 65 20 61 |ES.Liste|d here a|
|00004c10| 72 65 20 73 6f 6d 65 20 | 6f 66 20 74 68 65 20 69 |re some |of the i|
|00004c20| 6d 70 6f 72 74 61 6e 74 | 20 64 61 74 61 20 73 74 |mportant| data st|
|00004c30| 72 75 63 74 75 72 65 73 | 20 75 73 65 64 20 62 79 |ructures| used by|
|00004c40| 20 4d 75 6c 74 69 42 75 | 66 66 65 72 2e 20 41 6c | MultiBu|ffer. Al|
|00004c50| 6c 20 6f 66 20 74 68 65 | 6d 20 63 61 6e 20 62 65 |l of the|m can be|
|00004c60| 20 66 6f 75 6e 64 20 69 | 6e 20 74 68 65 20 66 69 | found i|n the fi|
|00004c70| 6c 65 20 44 6f 75 62 6c | 65 42 75 66 66 65 72 2e |le Doubl|eBuffer.|
|00004c80| 68 2e 0d 74 79 70 65 64 | 65 66 20 73 74 72 75 63 |h..typed|ef struc|
|00004c90| 74 20 7b 0d 09 50 61 72 | 61 6d 42 6c 6f 63 6b 48 |t {..Par|amBlockH|
|00004ca0| 65 61 64 65 72 0d 09 73 | 68 6f 72 74 09 09 69 6f |eader..s|hort..io|
|00004cb0| 46 52 65 66 4e 75 6d 3b | 0d 09 6c 6f 6e 67 09 09 |FRefNum;|..long..|
|00004cc0| 09 66 69 6c 6c 65 72 31 | 3b 0d 09 73 68 6f 72 74 |.filler1|;..short|
|00004cd0| 09 09 66 69 6c 6c 65 72 | 32 3b 0d 09 50 74 72 09 |..filler|2;..Ptr.|
|00004ce0| 09 09 69 6f 42 75 66 66 | 65 72 3b 0d 09 6c 6f 6e |..ioBuff|er;..lon|
|00004cf0| 67 09 09 09 69 6f 52 65 | 71 43 6f 75 6e 74 3b 0d |g...ioRe|qCount;.|
|00004d00| 09 6c 6f 6e 67 09 09 09 | 69 6f 41 63 74 43 6f 75 |.long...|ioActCou|
|00004d10| 6e 74 3b 0d 09 73 68 6f | 72 74 09 09 69 6f 50 6f |nt;..sho|rt..ioPo|
|00004d20| 73 4d 6f 64 65 3b 0d 09 | 6c 6f 6e 67 09 09 09 69 |sMode;..|long...i|
|00004d30| 6f 50 6f 73 4f 66 66 73 | 65 74 3b 0d 7d 20 73 74 |oPosOffs|et;.} st|
|00004d40| 72 69 70 70 65 64 44 6f | 77 6e 52 65 61 64 50 42 |rippedDo|wnReadPB|
|00004d50| 2c 20 2a 73 74 72 69 70 | 70 65 64 44 6f 77 6e 52 |, *strip|pedDownR|
|00004d60| 65 61 64 50 42 50 74 72 | 3b 0d 54 68 65 20 73 74 |eadPBPtr|;.The st|
|00004d70| 72 69 70 70 65 64 44 6f | 77 6e 52 65 61 64 50 42 |rippedDo|wnReadPB|
|00004d80| 20 73 74 72 75 63 74 75 | 72 65 20 69 73 20 74 68 | structu|re is th|
|00004d90| 65 20 6d 69 6e 69 6d 61 | 6c 20 70 61 72 61 6d 65 |e minima|l parame|
|00004da0| 74 65 72 20 62 6c 6f 63 | 6b 20 74 68 65 20 44 65 |ter bloc|k the De|
|00004db0| 76 69 63 65 20 4d 61 6e | 61 67 65 72 20 6e 65 65 |vice Man|ager nee|
|00004dc0| 64 73 20 69 6e 20 6f 72 | 64 65 72 20 74 6f 20 65 |ds in or|der to e|
|00004dd0| 78 65 63 75 74 65 20 61 | 20 72 65 61 64 20 66 72 |xecute a| read fr|
|00004de0| 6f 6d 20 61 20 66 69 6c | 65 2e 20 41 20 70 72 69 |om a fil|e. A pri|
|00004df0| 6d 61 72 79 20 63 6f 6e | 63 65 72 6e 20 77 61 73 |mary con|cern was|
|00004e00| 20 6b 65 65 70 69 6e 67 | 20 0d 4d 75 6c 74 69 42 | keeping| .MultiB|
|00004e10| 75 66 66 65 72 d5 73 20 | 6f 76 65 72 68 65 61 64 |uffer.s |overhead|
|00004e20| 20 76 65 72 79 20 6c 6f | 77 2c 20 61 6e 64 20 73 | very lo|w, and s|
|00004e30| 69 6e 63 65 20 65 61 63 | 68 20 62 75 66 66 65 72 |ince eac|h buffer|
|00004e40| 20 6e 65 65 64 73 20 74 | 6f 20 68 61 76 65 20 61 | needs t|o have a|
|00004e50| 20 70 61 72 61 6d 65 74 | 65 72 20 62 6c 6f 63 6b | paramet|er block|
|00004e60| 20 61 73 73 6f 63 69 61 | 74 65 64 20 77 69 74 68 | associa|ted with|
|00004e70| 20 69 74 2c 20 75 73 69 | 6e 67 20 74 68 65 20 66 | it, usi|ng the f|
|00004e80| 75 6c 6c 2d 62 6c 6f 77 | 6e 20 50 61 72 61 6d 42 |ull-blow|n ParamB|
|00004e90| 6c 6f 63 6b 52 65 63 20 | 77 61 73 20 75 6e 64 65 |lockRec |was unde|
|00004ea0| 73 69 72 61 62 6c 65 2e | 0d 74 79 70 65 64 65 66 |sirable.|.typedef|
|00004eb0| 20 73 74 72 75 63 74 20 | 7b 0d 09 73 74 72 69 70 | struct |{..strip|
|00004ec0| 70 65 64 44 6f 77 6e 52 | 65 61 64 50 42 09 70 62 |pedDownR|eadPB.pb|
|00004ed0| 3b 0d 09 50 74 72 09 09 | 09 09 09 09 75 73 65 72 |;..Ptr..|....user|
|00004ee0| 49 6e 66 6f 3b 0d 09 73 | 68 6f 72 74 09 09 09 09 |Info;..s|hort....|
|00004ef0| 09 68 65 61 64 65 72 4e | 75 6d 3b 0d 7d 20 45 78 |.headerN|um;.} Ex|
|00004f00| 74 50 61 72 61 6d 42 6c | 6f 63 6b 52 65 63 2c 20 |tParamBl|ockRec, |
|00004f10| 2a 45 78 74 50 61 72 6d | 42 6c 6b 50 74 72 3b 0d |*ExtParm|BlkPtr;.|
|00004f20| 45 78 74 50 61 72 61 6d | 42 6c 6f 63 6b 52 65 63 |ExtParam|BlockRec|
|00004f30| 20 69 73 20 61 20 77 72 | 61 70 70 65 72 20 74 68 | is a wr|apper th|
|00004f40| 61 74 20 61 64 64 73 20 | 61 20 66 65 77 20 70 69 |at adds |a few pi|
|00004f50| 65 63 65 73 20 6f 66 20 | 4d 75 6c 74 69 42 75 66 |eces of |MultiBuf|
|00004f60| 66 65 72 2d 73 70 65 63 | 69 66 69 63 20 69 6e 66 |fer-spec|ific inf|
|00004f70| 6f 72 6d 61 74 69 6f 6e | 20 74 6f 20 74 68 65 20 |ormation| to the |
|00004f80| 65 6e 64 20 6f 66 20 61 | 20 70 61 72 61 6d 65 74 |end of a| paramet|
|00004f90| 65 72 20 62 6c 6f 63 6b | 2e 20 49 74 20 61 6c 6c |er block|. It all|
|00004fa0| 6f 77 73 20 75 73 20 74 | 6f 20 67 65 74 20 69 6e |ows us t|o get in|
|00004fb0| 66 6f 72 6d 61 74 69 6f | 6e 20 61 62 6f 75 74 20 |formatio|n about |
|00004fc0| 74 68 65 20 73 74 61 74 | 65 20 6f 66 20 74 68 65 |the stat|e of the|
|00004fd0| 20 70 72 6f 67 72 61 6d | 20 74 6f 20 74 68 65 20 | program| to the |
|00004fe0| 63 6f 6d 70 6c 65 74 69 | 6f 6e 20 72 6f 75 74 69 |completi|on routi|
|00004ff0| 6e 65 20 77 69 74 68 6f | 75 74 20 75 73 69 6e 67 |ne witho|ut using|
|00005000| 20 61 6e 79 20 67 6c 6f | 62 61 6c 73 2c 20 77 68 | any glo|bals, wh|
|00005010| 69 63 68 20 77 6f 75 6c | 64 20 6d 61 6b 65 20 66 |ich woul|d make f|
|00005020| 6f 72 20 75 67 6c 79 20 | 63 6f 64 65 2e 0d 74 79 |or ugly |code..ty|
|00005030| 70 65 64 65 66 20 73 74 | 72 75 63 74 20 7b 0d 09 |pedef st|ruct {..|
|00005040| 73 68 6f 72 74 09 09 09 | 09 09 66 6c 61 67 73 3b |short...|..flags;|
|00005050| 0d 09 45 78 74 50 61 72 | 61 6d 42 6c 6f 63 6b 52 |..ExtPar|amBlockR|
|00005060| 65 63 09 09 72 65 61 64 | 50 42 3b 0d 09 44 65 66 |ec..read|PB;..Def|
|00005070| 65 72 72 65 64 54 61 73 | 6b 09 09 09 64 74 3b 0d |erredTas|k...dt;.|
|00005080| 09 53 6f 75 6e 64 48 65 | 61 64 65 72 50 74 72 09 |.SoundHe|aderPtr.|
|00005090| 09 68 65 61 64 65 72 3b | 0d 7d 20 53 61 6d 70 6c |.header;|.} Sampl|
|000050a0| 65 42 75 66 66 65 72 2c | 20 2a 53 61 6d 70 6c 65 |eBuffer,| *Sample|
|000050b0| 42 75 66 66 65 72 50 74 | 72 3b 0d 53 61 6d 70 6c |BufferPt|r;.Sampl|
|000050c0| 65 42 75 66 66 65 72 20 | 63 6f 6e 74 61 69 6e 73 |eBuffer |contains|
|000050d0| 20 61 6c 6c 20 74 68 65 | 20 69 6e 66 6f 72 6d 61 | all the| informa|
|000050e0| 74 69 6f 6e 20 6e 65 63 | 65 73 73 61 72 79 20 66 |tion nec|essary f|
|000050f0| 6f 72 20 6d 61 6e 61 67 | 69 6e 67 20 73 61 6d 70 |or manag|ing samp|
|00005100| 6c 65 73 2e 20 54 68 65 | 20 66 6c 61 67 73 20 66 |les. The| flags f|
|00005110| 69 65 6c 64 20 68 6f 6c | 64 73 20 74 68 65 20 63 |ield hol|ds the c|
|00005120| 75 72 72 65 6e 74 20 73 | 74 61 74 75 73 20 6f 66 |urrent s|tatus of|
|00005130| 20 74 68 65 20 62 75 66 | 66 65 72 2e 20 54 68 65 | the buf|fer. The|
|00005140| 20 72 65 61 64 50 42 20 | 66 69 65 6c 64 20 69 73 | readPB |field is|
|00005150| 20 74 68 65 20 70 61 72 | 61 6d 65 74 65 72 20 62 | the par|ameter b|
|00005160| 6c 6f 63 6b 20 74 68 65 | 20 44 65 76 69 63 65 20 |lock the| Device |
|00005170| 4d 61 6e 61 67 65 72 20 | 75 73 65 73 20 74 6f 20 |Manager |uses to |
|00005180| 72 65 61 64 20 74 68 65 | 20 64 61 74 61 20 66 72 |read the| data fr|
|00005190| 6f 6d 20 74 68 65 20 73 | 6f 75 72 63 65 2e 20 53 |om the s|ource. S|
|000051a0| 69 6e 63 65 20 69 74 d5 | 73 20 70 6f 73 73 69 62 |ince it.|s possib|
|000051b0| 6c 65 20 74 68 61 74 20 | 79 6f 75 d5 6c 6c 20 68 |le that |you.ll h|
|000051c0| 61 76 65 20 6d 6f 72 65 | 20 74 68 61 6e 20 6f 6e |ave more| than on|
|000051d0| 65 20 61 73 79 6e 63 68 | 72 6f 6e 6f 75 73 20 72 |e asynch|ronous r|
|000051e0| 65 61 64 20 71 75 65 75 | 65 64 20 61 74 20 61 20 |ead queu|ed at a |
|000051f0| 74 69 6d 65 2c 20 72 65 | 75 73 69 6e 67 20 70 61 |time, re|using pa|
|00005200| 72 61 6d 65 74 65 72 20 | 62 6c 6f 63 6b 73 20 69 |rameter |blocks i|
|00005210| 73 20 69 6e 61 64 76 69 | 73 61 62 6c 65 2c 20 68 |s inadvi|sable, h|
|00005220| 65 6e 63 65 20 74 68 65 | 20 6e 65 65 64 20 66 6f |ence the| need fo|
|00005230| 72 20 6f 6e 65 20 61 73 | 73 6f 63 69 61 74 65 64 |r one as|sociated|
|00005240| 20 77 69 74 68 20 65 61 | 63 68 20 62 75 66 66 65 | with ea|ch buffe|
|00005250| 72 2e 20 54 68 65 20 64 | 74 20 66 69 65 6c 64 20 |r. The d|t field |
|00005260| 69 73 20 61 20 64 65 66 | 65 72 72 65 64 20 74 61 |is a def|erred ta|
|00005270| 73 6b 20 72 65 63 6f 72 | 64 20 74 68 61 74 20 77 |sk recor|d that w|
|00005280| 69 6c 6c 20 62 65 20 75 | 73 65 64 20 74 6f 20 69 |ill be u|sed to i|
|00005290| 6e 73 74 61 6c 6c 20 74 | 68 65 20 50 72 6f 63 65 |nstall t|he Proce|
|000052a0| 73 73 69 6e 67 50 72 6f | 63 2e 20 54 68 65 20 68 |ssingPro|c. The h|
|000052b0| 65 61 64 65 72 20 66 69 | 65 6c 64 20 69 73 20 61 |eader fi|eld is a|
|000052c0| 20 70 6f 69 6e 74 65 72 | 20 74 6f 20 61 20 73 6f | pointer| to a so|
|000052d0| 75 6e 64 20 68 65 61 64 | 65 72 20 74 68 61 74 20 |und head|er that |
|000052e0| 74 68 65 20 53 6f 75 6e | 64 20 4d 61 6e 61 67 65 |the Soun|d Manage|
|000052f0| 72 20 75 73 65 73 20 74 | 6f 20 70 6c 61 79 20 61 |r uses t|o play a|
|00005300| 20 73 61 6d 70 6c 65 2e | 20 4e 6f 74 65 20 74 68 | sample.| Note th|
|00005310| 61 74 20 74 68 65 20 73 | 6f 75 6e 64 20 68 65 61 |at the s|ound hea|
|00005320| 64 65 72 20 64 65 66 69 | 6e 69 74 69 6f 6e 2c 20 |der defi|nition, |
|00005330| 66 6f 75 6e 64 20 69 6e | 20 53 6f 75 6e 64 2e 68 |found in| Sound.h|
|00005340| 2c 20 63 6f 6e 74 61 69 | 6e 73 20 61 20 73 61 6d |, contai|ns a sam|
|00005350| 70 6c 65 50 74 72 20 74 | 68 61 74 20 77 69 6c 6c |plePtr t|hat will|
|00005360| 20 68 61 76 65 20 61 20 | 6e 6f 6e 72 65 6c 6f 63 | have a |nonreloc|
|00005370| 61 74 61 62 6c 65 20 62 | 6c 6f 63 6b 20 61 73 73 |atable b|lock ass|
|00005380| 6f 63 69 61 74 65 64 20 | 77 69 74 68 20 69 74 20 |ociated |with it |
|00005390| 66 6f 72 20 68 6f 6c 64 | 69 6e 67 20 74 68 65 20 |for hold|ing the |
|000053a0| 61 63 74 75 61 6c 20 73 | 61 6d 70 6c 65 20 64 61 |actual s|ample da|
|000053b0| 74 61 2e 0d 74 79 70 65 | 64 65 66 20 73 74 72 75 |ta..type|def stru|
|000053c0| 63 74 20 7b 0d 09 4f 53 | 54 79 70 65 09 09 09 09 |ct {..OS|Type....|
|000053d0| 09 73 69 67 6e 61 74 75 | 72 65 3b 0d 09 6c 6f 6e |.signatu|re;..lon|
|000053e0| 67 09 09 09 09 09 09 72 | 65 66 4e 75 6d 3b 0d 09 |g......r|efNum;..|
|000053f0| 6c 6f 6e 67 09 09 09 09 | 09 09 66 69 6c 65 44 61 |long....|..fileDa|
|00005400| 74 61 53 74 61 72 74 3b | 0d 09 6c 6f 6e 67 09 09 |taStart;|..long..|
|00005410| 09 09 09 09 62 79 74 65 | 73 54 6f 47 6f 3b 0d 09 |....byte|sToGo;..|
|00005420| 73 68 6f 72 74 09 09 09 | 09 09 63 75 72 72 65 6e |short...|..curren|
|00005430| 74 42 75 66 66 65 72 3b | 0d 09 53 61 6d 70 6c 65 |tBuffer;|..Sample|
|00005440| 42 75 66 66 65 72 09 09 | 09 62 75 66 66 65 72 73 |Buffer..|.buffers|
|00005450| 5b 6b 4e 75 6d 42 75 66 | 66 65 72 73 5d 3b 0d 09 |[kNumBuf|fers];..|
|00005460| 53 6e 64 43 6f 6d 6d 61 | 6e 64 09 09 09 09 62 43 |SndComma|nd....bC|
|00005470| 6d 64 3b 0d 09 53 6e 64 | 43 6f 6d 6d 61 6e 64 09 |md;..Snd|Command.|
|00005480| 09 09 09 63 62 43 6d 64 | 3b 0d 09 53 6e 64 43 61 |...cbCmd|;..SndCa|
|00005490| 6c 6c 42 61 63 6b 50 72 | 6f 63 50 74 72 09 6f 6c |llBackPr|ocPtr.ol|
|000054a0| 64 43 61 6c 6c 42 61 63 | 6b 3b 0d 09 6c 6f 6e 67 |dCallBac|k;..long|
|000054b0| 09 09 09 09 09 09 6f 6c | 64 55 73 65 72 49 6e 66 |......ol|dUserInf|
|000054c0| 6f 3b 0d 09 6c 6f 6e 67 | 09 09 09 09 09 09 61 35 |o;..long|......a5|
|000054d0| 72 65 66 3b 0d 7d 20 50 | 72 69 76 61 74 65 44 42 |ref;.} P|rivateDB|
|000054e0| 49 6e 66 6f 2c 20 2a 50 | 72 69 76 61 74 65 44 42 |Info, *P|rivateDB|
|000054f0| 49 6e 66 6f 50 74 72 3b | 0d 50 72 69 76 61 74 65 |InfoPtr;|.Private|
|00005500| 44 42 49 6e 66 6f 20 69 | 73 20 61 20 70 72 69 76 |DBInfo i|s a priv|
|00005510| 61 74 65 20 64 61 74 61 | 20 73 74 72 75 63 74 75 |ate data| structu|
|00005520| 72 65 20 74 68 61 74 20 | 63 6f 6e 74 61 69 6e 73 |re that |contains|
|00005530| 20 61 6c 6c 20 74 68 65 | 20 69 6e 66 6f 72 6d 61 | all the| informa|
|00005540| 74 69 6f 6e 20 4d 75 6c | 74 69 42 75 66 66 65 72 |tion Mul|tiBuffer|
|00005550| 20 72 65 71 75 69 72 65 | 73 20 74 6f 20 64 6f 20 | require|s to do |
|00005560| 69 74 73 20 74 68 69 6e | 67 2e 20 54 68 65 20 72 |its thin|g. The r|
|00005570| 65 66 4e 75 6d 20 66 69 | 65 6c 64 20 63 6f 6e 74 |efNum fi|eld cont|
|00005580| 61 69 6e 73 20 74 68 65 | 20 72 65 66 65 72 65 6e |ains the| referen|
|00005590| 63 65 20 6e 75 6d 62 65 | 72 20 6f 66 20 74 68 65 |ce numbe|r of the|
|000055a0| 20 66 69 6c 65 20 6f 72 | 20 64 65 76 69 63 65 20 | file or| device |
|000055b0| 74 68 61 74 20 63 6f 6e | 74 61 69 6e 73 20 74 68 |that con|tains th|
|000055c0| 65 20 73 6f 75 6e 64 20 | 64 61 74 61 20 77 65 d5 |e sound |data we.|
|000055d0| 72 65 20 67 6f 69 6e 67 | 20 74 6f 20 70 6c 61 79 |re going| to play|
|000055e0| 2e 20 41 73 20 69 6d 70 | 6c 65 6d 65 6e 74 65 64 |. As imp|lemented|
|000055f0| 20 68 65 72 65 2c 20 4d | 75 6c 74 69 42 75 66 66 | here, M|ultiBuff|
|00005600| 65 72 20 72 65 61 64 73 | 20 69 6e 66 6f 72 6d 61 |er reads| informa|
|00005610| 74 69 6f 6e 20 66 72 6f | 6d 20 61 20 66 69 6c 65 |tion fro|m a file|
|00005620| 20 6f 6e 20 61 6e 20 48 | 46 53 20 64 65 76 69 63 | on an H|FS devic|
|00005630| 65 2c 20 73 6f 20 72 65 | 66 4e 75 6d 20 77 69 6c |e, so re|fNum wil|
|00005640| 6c 20 63 6f 6e 74 61 69 | 6e 20 61 20 46 69 6c 65 |l contai|n a File|
|00005650| 20 4d 61 6e 61 67 65 72 | 20 66 69 6c 65 20 72 65 | Manager| file re|
|00005660| 66 65 72 65 6e 63 65 20 | 6e 75 6d 62 65 72 2e 20 |ference |number. |
|00005670| 49 74 d5 73 20 61 6c 73 | 6f 20 70 6f 73 73 69 62 |It.s als|o possib|
|00005680| 6c 65 20 74 6f 20 75 73 | 65 20 61 20 73 6f 75 6e |le to us|e a soun|
|00005690| 64 20 69 6e 70 75 74 20 | 64 65 76 69 63 65 20 6f |d input |device o|
|000056a0| 72 20 74 68 65 20 6e 65 | 74 77 6f 72 6b 20 61 73 |r the ne|twork as|
|000056b0| 20 74 68 65 20 73 6f 75 | 72 63 65 20 66 6f 72 20 | the sou|rce for |
|000056c0| 79 6f 75 72 20 73 6f 75 | 6e 64 20 64 61 74 61 2e |your sou|nd data.|
|000056d0| 20 49 6e 20 73 75 63 68 | 20 63 61 73 65 73 20 72 | In such| cases r|
|000056e0| 65 66 4e 75 6d 20 77 6f | 75 6c 64 20 63 6f 6e 74 |efNum wo|uld cont|
|000056f0| 61 69 6e 20 61 20 73 6f | 75 6e 64 20 69 6e 70 75 |ain a so|und inpu|
|00005700| 74 20 64 65 76 69 63 65 | 20 72 65 66 65 72 65 6e |t device| referen|
|00005710| 63 65 20 6e 75 6d 62 65 | 72 20 6f 72 20 61 6e 20 |ce numbe|r or an |
|00005720| 41 70 70 6c 65 54 61 6c | 6b 20 75 6e 69 74 20 72 |AppleTal|k unit r|
|00005730| 65 66 65 72 65 6e 63 65 | 20 6e 75 6d 62 65 72 2c |eference| number,|
|00005740| 20 72 65 73 70 65 63 74 | 69 76 65 6c 79 2e 20 54 | respect|ively. T|
|00005750| 68 65 20 66 69 65 6c 64 | 20 66 69 6c 65 44 61 74 |he field| fileDat|
|00005760| 61 53 74 61 72 74 20 63 | 6f 6e 74 61 69 6e 73 20 |aStart c|ontains |
|00005770| 74 68 65 20 70 6f 73 69 | 74 69 6f 6e 20 69 6e 20 |the posi|tion in |
|00005780| 74 68 65 20 66 69 6c 65 | 20 61 74 20 77 68 69 63 |the file| at whic|
|00005790| 68 20 74 68 65 20 61 63 | 74 75 61 6c 20 73 6f 75 |h the ac|tual sou|
|000057a0| 6e 64 20 64 61 74 61 20 | 73 74 61 72 74 73 3b 20 |nd data |starts; |
|000057b0| 73 69 6e 63 65 20 41 49 | 46 46 20 66 69 6c 65 73 |since AI|FF files|
|000057c0| 20 61 6e 64 20 72 65 73 | 6f 75 72 63 65 73 20 63 | and res|ources c|
|000057d0| 61 6e 20 63 6f 6e 74 61 | 69 6e 20 74 65 6e 73 20 |an conta|in tens |
|000057e0| 6f 66 20 62 79 74 65 73 | 20 6f 66 20 68 65 61 64 |of bytes| of head|
|000057f0| 65 72 20 69 6e 66 6f 72 | 6d 61 74 69 6f 6e 2c 20 |er infor|mation, |
|00005800| 69 74 d5 73 20 69 6d 70 | 6f 72 74 61 6e 74 20 74 |it.s imp|ortant t|
|00005810| 6f 20 62 65 20 61 62 6c | 65 20 74 6f 20 6c 6f 63 |o be abl|e to loc|
|00005820| 61 74 65 20 74 68 65 20 | 73 74 61 72 74 20 6f 66 |ate the |start of|
|00005830| 20 6f 75 72 20 64 61 74 | 61 2e 20 54 68 65 20 62 | our dat|a. The b|
|00005840| 79 74 65 73 54 6f 47 6f | 20 66 69 65 6c 64 20 6b |ytesToGo| field k|
|00005850| 65 65 70 73 20 74 72 61 | 63 6b 20 6f 66 20 74 68 |eeps tra|ck of th|
|00005860| 65 20 6e 75 6d 62 65 72 | 20 6f 66 20 62 79 74 65 |e number| of byte|
|00005870| 73 20 6f 66 20 73 6f 75 | 6e 64 20 64 61 74 61 20 |s of sou|nd data |
|00005880| 74 6f 20 62 65 20 70 6c | 61 79 65 64 2e 20 54 68 |to be pl|ayed. Th|
|00005890| 69 73 20 66 69 65 6c 64 | 20 6d 61 79 20 6e 6f 74 |is field| may not|
|000058a0| 20 62 65 20 6d 65 61 6e | 69 6e 67 66 75 6c 20 69 | be mean|ingful i|
|000058b0| 6e 20 74 68 65 20 63 61 | 73 65 20 6f 66 20 63 6f |n the ca|se of co|
|000058c0| 6e 74 69 6e 75 6f 75 73 | 20 73 6f 75 6e 64 20 73 |ntinuous| sound s|
|000058d0| 6f 75 72 63 65 73 2c 20 | 73 69 6e 63 65 20 74 68 |ources, |since th|
|000058e0| 65 20 64 61 74 61 20 73 | 74 72 65 61 6d 20 64 6f |e data s|tream do|
|000058f0| 65 73 6e d5 74 20 6e 65 | 63 65 73 73 61 72 69 6c |esn.t ne|cessaril|
|00005900| 79 20 68 61 76 65 20 61 | 20 64 65 66 69 6e 69 74 |y have a| definit|
|00005910| 65 20 65 6e 64 2e 0d 54 | 68 65 20 63 75 72 72 65 |e end..T|he curre|
|00005920| 6e 74 42 75 66 66 65 72 | 20 66 69 65 6c 64 20 63 |ntBuffer| field c|
|00005930| 6f 6e 74 61 69 6e 73 20 | 74 68 65 20 6e 75 6d 62 |ontains |the numb|
|00005940| 65 72 20 6f 66 20 74 68 | 65 20 62 75 66 66 65 72 |er of th|e buffer|
|00005950| 20 74 68 61 74 d5 73 20 | 63 75 72 72 65 6e 74 6c | that.s |currentl|
|00005960| 79 20 70 6c 61 79 69 6e | 67 2e 20 54 68 69 73 20 |y playin|g. This |
|00005970| 66 69 65 6c 64 20 63 61 | 6e 20 61 63 74 75 61 6c |field ca|n actual|
|00005980| 6c 79 20 62 65 20 74 68 | 6f 75 67 68 74 20 6f 66 |ly be th|ought of|
|00005990| 20 61 73 20 61 6e 20 69 | 6e 64 65 78 20 69 6e 74 | as an i|ndex int|
|000059a0| 6f 20 74 68 65 20 61 72 | 72 61 79 20 6f 66 20 53 |o the ar|ray of S|
|000059b0| 61 6d 70 6c 65 42 75 66 | 66 65 72 73 2e 20 49 6e |ampleBuf|fers. In|
|000059c0| 20 74 68 69 73 20 61 72 | 72 61 79 2c 20 62 75 66 | this ar|ray, buf|
|000059d0| 66 65 72 73 5b 6b 4e 75 | 6d 42 75 66 66 65 72 73 |fers[kNu|mBuffers|
|000059e0| 5d 20 63 6f 6e 74 61 69 | 6e 73 20 74 68 65 20 69 |] contai|ns the i|
|000059f0| 6e 66 6f 72 6d 61 74 69 | 6f 6e 20 6e 65 65 64 65 |nformati|on neede|
|00005a00| 64 20 66 6f 72 20 61 63 | 74 75 61 6c 6c 79 20 70 |d for ac|tually p|
|00005a10| 6c 61 79 69 6e 67 20 74 | 68 65 20 73 6f 75 6e 64 |laying t|he sound|
|00005a20| 20 74 68 72 6f 75 67 68 | 20 74 68 65 20 53 6f 75 | through| the Sou|
|00005a30| 6e 64 20 4d 61 6e 61 67 | 65 72 20 28 61 6e 64 20 |nd Manag|er (and |
|00005a40| 73 6f 6d 65 20 6f 74 68 | 65 72 20 63 6f 6e 76 65 |some oth|er conve|
|00005a50| 6e 69 65 6e 74 20 67 6f | 6f 64 69 65 73 2c 20 74 |nient go|odies, t|
|00005a60| 6f 6f 29 2e 0d 62 43 6d | 64 20 61 6e 64 20 63 62 |oo)..bCm|d and cb|
|00005a70| 43 6d 64 20 61 72 65 20 | 73 6f 75 6e 64 20 63 6f |Cmd are |sound co|
|00005a80| 6d 6d 61 6e 64 73 20 74 | 68 61 74 20 61 72 65 20 |mmands t|hat are |
|00005a90| 75 73 65 64 20 74 6f 20 | 73 65 6e 64 20 61 20 66 |used to |send a f|
|00005aa0| 72 61 6d 65 20 6f 66 66 | 20 74 6f 20 62 65 20 70 |rame off| to be p|
|00005ab0| 6c 61 79 65 64 20 62 79 | 20 74 68 65 20 53 6f 75 |layed by| the Sou|
|00005ac0| 6e 64 20 4d 61 6e 61 67 | 65 72 2e 20 62 43 6d 64 |nd Manag|er. bCmd|
|00005ad0| 20 63 6f 6e 74 61 69 6e | 73 20 74 68 65 20 69 6e | contain|s the in|
|00005ae0| 66 6f 72 6d 61 74 69 6f | 6e 20 6e 65 63 65 73 73 |formatio|n necess|
|00005af0| 61 72 79 20 74 6f 20 69 | 73 73 75 65 20 61 20 62 |ary to i|ssue a b|
|00005b00| 75 66 66 65 72 43 6d 64 | 2c 20 61 6e 64 20 63 62 |ufferCmd|, and cb|
|00005b10| 43 6d 64 20 69 73 20 75 | 73 65 64 20 74 6f 20 69 |Cmd is u|sed to i|
|00005b20| 73 73 75 65 20 61 20 63 | 61 6c 6c 42 61 63 6b 43 |ssue a c|allBackC|
|00005b30| 6d 64 2e 20 42 6f 74 68 | 20 6f 66 20 74 68 65 73 |md. Both| of thes|
|00005b40| 65 20 73 74 72 75 63 74 | 75 72 65 73 20 61 72 65 |e struct|ures are|
|00005b50| 20 75 73 65 64 20 66 72 | 65 71 75 65 6e 74 6c 79 | used fr|equently|
|00005b60| 20 77 69 74 68 20 6c 69 | 74 74 6c 65 20 6d 6f 64 | with li|ttle mod|
|00005b70| 69 66 69 63 61 74 69 6f | 6e 3b 20 62 79 20 68 61 |ificatio|n; by ha|
|00005b80| 76 69 6e 67 20 74 68 65 | 6d 20 70 72 65 69 6e 69 |ving the|m preini|
|00005b90| 74 69 61 6c 69 7a 65 64 | 20 61 6e 64 20 65 61 73 |tialized| and eas|
|00005ba0| 69 6c 79 20 61 63 63 65 | 73 73 69 62 6c 65 20 74 |ily acce|ssible t|
|00005bb0| 6f 20 74 68 65 20 72 6f | 75 74 69 6e 65 73 20 74 |o the ro|utines t|
|00005bc0| 68 61 74 20 6e 65 65 64 | 20 74 68 65 6d 2c 20 77 |hat need| them, w|
|00005bd0| 65 20 73 61 76 65 20 61 | 20 66 65 77 20 69 6e 73 |e save a| few ins|
|00005be0| 74 72 75 63 74 69 6f 6e | 73 2e 0d 6f 6c 64 43 61 |truction|s..oldCa|
|00005bf0| 6c 6c 42 61 63 6b 20 61 | 6e 64 20 6f 6c 64 55 73 |llBack a|nd oldUs|
|00005c00| 65 72 49 6e 66 6f 20 61 | 72 65 20 68 6f 6c 64 69 |erInfo a|re holdi|
|00005c10| 6e 67 20 73 70 6f 74 73 | 20 66 6f 72 20 61 6e 79 |ng spots| for any|
|00005c20| 20 75 73 65 72 49 6e 66 | 6f 20 61 6e 64 20 63 61 | userInf|o and ca|
|00005c30| 6c 6c 42 61 63 6b 20 64 | 61 74 61 20 73 74 6f 72 |llBack d|ata stor|
|00005c40| 65 64 20 69 6e 20 74 68 | 65 20 53 6e 64 43 68 61 |ed in th|e SndCha|
|00005c50| 6e 6e 65 6c 20 64 61 74 | 61 20 73 74 72 75 63 74 |nnel dat|a struct|
|00005c60| 75 72 65 20 62 65 66 6f | 72 65 20 4d 75 6c 74 69 |ure befo|re Multi|
|00005c70| 42 75 66 66 65 72 20 77 | 61 73 20 63 61 6c 6c 65 |Buffer w|as calle|
|00005c80| 64 2e 20 4d 75 6c 74 69 | 42 75 66 66 65 72 20 70 |d. Multi|Buffer p|
|00005c90| 6c 61 63 65 73 20 69 74 | 73 20 6f 77 6e 20 69 6e |laces it|s own in|
|00005ca0| 66 6f 72 6d 61 74 69 6f | 6e 20 69 6e 20 74 68 65 |formatio|n in the|
|00005cb0| 20 75 73 65 72 49 6e 66 | 6f 20 61 6e 64 20 63 61 | userInf|o and ca|
|00005cc0| 6c 6c 42 61 63 6b 20 66 | 69 65 6c 64 73 2c 20 73 |llBack f|ields, s|
|00005cd0| 6f 20 69 74 d5 73 20 69 | 6d 70 6f 72 74 61 6e 74 |o it.s i|mportant|
|00005ce0| 20 74 6f 20 73 61 76 65 | 20 61 6e 64 20 72 65 73 | to save| and res|
|00005cf0| 74 6f 72 65 20 61 6e 79 | 20 76 61 6c 75 65 73 20 |tore any| values |
|00005d00| 74 68 61 74 20 6d 61 79 | 20 68 61 76 65 20 62 65 |that may| have be|
|00005d10| 65 6e 20 6c 75 72 6b 69 | 6e 67 20 74 68 65 72 65 |en lurki|ng there|
|00005d20| 20 70 72 65 76 69 6f 75 | 73 6c 79 2e 0d 61 35 52 | previou|sly..a5R|
|00005d30| 65 66 20 63 6f 6e 74 61 | 69 6e 73 20 61 20 72 65 |ef conta|ins a re|
|00005d40| 66 65 72 65 6e 63 65 20 | 74 6f 20 74 68 65 20 61 |ference |to the a|
|00005d50| 70 70 6c 69 63 61 74 69 | 6f 6e d5 73 20 41 35 20 |pplicati|on.s A5 |
|00005d60| 77 6f 72 6c 64 2c 20 73 | 6f 20 74 68 61 74 20 77 |world, s|o that w|
|00005d70| 65 20 63 61 6e 20 61 63 | 63 65 73 73 20 74 68 65 |e can ac|cess the|
|00005d80| 20 67 6c 6f 62 61 6c 20 | 76 61 72 69 61 62 6c 65 | global |variable|
|00005d90| 73 20 74 68 61 74 20 4d | 75 6c 74 69 42 75 66 66 |s that M|ultiBuff|
|00005da0| 65 72 20 75 73 65 73 20 | 61 74 20 74 69 6d 65 73 |er uses |at times|
|00005db0| 20 77 68 65 6e 20 41 35 | 20 6d 61 79 20 62 65 20 | when A5| may be |
|00005dc0| 69 6e 76 61 6c 69 64 2c | 20 73 75 63 68 20 61 73 |invalid,| such as|
|00005dd0| 20 61 74 20 69 6e 74 65 | 72 72 75 70 74 20 74 69 | at inte|rrupt ti|
|00005de0| 6d 65 2e 0d 54 48 45 20 | 52 4f 55 54 49 4e 45 53 |me..THE |ROUTINES|
|00005df0| 0d 54 68 69 73 20 73 65 | 63 74 69 6f 6e 20 64 65 |.This se|ction de|
|00005e00| 73 63 72 69 62 65 73 20 | 73 75 70 70 6f 72 74 20 |scribes |support |
|00005e10| 72 6f 75 74 69 6e 65 73 | 20 74 68 61 74 20 6d 61 |routines| that ma|
|00005e20| 6b 65 20 75 70 20 4d 75 | 6c 74 69 42 75 66 66 65 |ke up Mu|ltiBuffe|
|00005e30| 72 2c 20 6d 61 6e 79 20 | 6f 66 20 77 68 69 63 68 |r, many |of which|
|00005e40| 20 63 61 6e 20 62 65 20 | 75 73 65 64 20 75 6e 63 | can be |used unc|
|00005e50| 68 61 6e 67 65 64 20 69 | 6e 20 79 6f 75 72 20 6f |hanged i|n your o|
|00005e60| 77 6e 20 63 6f 64 65 2e | 0d 73 68 6f 72 74 20 4f |wn code.|.short O|
|00005e70| 70 65 6e 41 49 46 46 46 | 69 6c 65 20 28 76 6f 69 |penAIFFF|ile (voi|
|00005e80| 64 29 0d 46 6f 75 6e 64 | 20 69 6e 09 41 49 46 46 |d).Found| in.AIFF|
|00005e90| 47 6f 6f 64 69 65 73 2e | 63 0d 4f 70 65 6e 41 49 |Goodies.|c.OpenAI|
|00005ea0| 46 46 46 69 6c 65 20 69 | 73 20 61 20 70 72 65 74 |FFFile i|s a pret|
|00005eb0| 74 79 20 67 65 6e 65 72 | 69 63 20 53 74 61 6e 64 |ty gener|ic Stand|
|00005ec0| 61 72 64 20 46 69 6c 65 | 2d 62 61 73 65 64 20 72 |ard File|-based r|
|00005ed0| 6f 75 74 69 6e 65 20 74 | 68 61 74 20 66 69 6c 74 |outine t|hat filt|
|00005ee0| 65 72 73 20 6f 75 74 20 | 61 6c 6c 20 66 69 6c 65 |ers out |all file|
|00005ef0| 20 74 79 70 65 73 20 6f | 74 68 65 72 20 74 68 61 | types o|ther tha|
|00005f00| 6e 20 27 41 49 46 46 27 | 20 66 69 6c 65 73 2e 20 |n 'AIFF'| files. |
|00005f10| 41 66 74 65 72 20 74 68 | 65 20 75 73 65 72 20 73 |After th|e user s|
|00005f20| 65 6c 65 63 74 73 20 61 | 20 66 69 6c 65 2c 20 74 |elects a| file, t|
|00005f30| 68 69 73 20 72 6f 75 74 | 69 6e 65 20 6f 70 65 6e |his rout|ine open|
|00005f40| 73 20 69 74 20 61 6e 64 | 20 72 65 74 75 72 6e 73 |s it and| returns|
|00005f50| 20 74 68 65 20 66 69 6c | 65 20 72 65 66 65 72 65 | the fil|e refere|
|00005f60| 6e 63 65 20 6e 75 6d 62 | 65 72 20 6f 72 20 61 6e |nce numb|er or an|
|00005f70| 20 4f 53 45 72 72 2e 0d | 0d 6c 6f 6e 67 20 47 65 | OSErr..|.long Ge|
|00005f80| 74 41 49 46 46 48 65 61 | 64 65 72 49 6e 66 6f 20 |tAIFFHea|derInfo |
|00005f90| 28 73 68 6f 72 74 20 66 | 72 65 66 4e 75 6d 2c 20 |(short f|refNum, |
|00005fa0| 53 6f 75 6e 64 48 65 61 | 64 65 72 50 74 72 20 74 |SoundHea|derPtr t|
|00005fb0| 68 65 48 65 61 64 65 72 | 29 0d 46 6f 75 6e 64 20 |heHeader|).Found |
|00005fc0| 69 6e 09 41 49 46 46 47 | 6f 6f 64 69 65 73 2e 63 |in.AIFFG|oodies.c|
|00005fd0| 0d 47 65 74 41 49 46 46 | 48 65 61 64 65 72 49 6e |.GetAIFF|HeaderIn|
|00005fe0| 66 6f 20 69 73 20 61 6e | 20 65 78 61 6d 70 6c 65 |fo is an| example|
|00005ff0| 20 6f 66 20 68 6f 77 20 | 74 6f 20 70 61 72 73 65 | of how |to parse|
|00006000| 20 74 68 65 20 68 65 61 | 64 65 72 20 69 6e 66 6f | the hea|der info|
|00006010| 72 6d 61 74 69 6f 6e 20 | 6f 75 74 20 6f 66 20 61 |rmation |out of a|
|00006020| 6e 20 41 49 46 46 20 66 | 69 6c 65 2e 20 54 68 65 |n AIFF f|ile. The|
|00006030| 20 62 61 73 69 63 20 73 | 74 72 61 74 65 67 79 20 | basic s|trategy |
|00006040| 69 73 20 74 6f 20 72 65 | 61 64 20 70 69 65 63 65 |is to re|ad piece|
|00006050| 73 20 6f 66 20 74 68 65 | 20 68 65 61 64 65 72 20 |s of the| header |
|00006060| 69 6e 74 6f 20 61 20 62 | 75 66 66 65 72 2c 20 77 |into a b|uffer, w|
|00006070| 68 65 72 65 20 61 20 73 | 74 72 75 63 74 20 74 65 |here a s|truct te|
|00006080| 6d 70 6c 61 74 65 20 63 | 61 6e 20 62 65 20 6f 76 |mplate c|an be ov|
|00006090| 65 72 6c 61 69 64 20 6f | 6e 74 6f 20 74 68 65 20 |erlaid o|nto the |
|000060a0| 64 61 74 61 2c 20 6d 61 | 6b 69 6e 67 20 74 68 65 |data, ma|king the|
|000060b0| 20 76 61 6c 75 65 73 20 | 65 61 73 79 20 74 6f 20 | values |easy to |
|000060c0| 61 63 63 65 73 73 2e 20 | 49 6d 70 6f 72 74 61 6e |access. |Importan|
|000060d0| 74 20 69 6e 66 6f 72 6d | 61 74 69 6f 6e 20 66 72 |t inform|ation fr|
|000060e0| 6f 6d 20 74 68 65 20 41 | 49 46 46 20 66 69 6c 65 |om the A|IFF file|
|000060f0| 20 63 61 6e 20 74 68 65 | 6e 20 62 65 20 70 75 74 | can the|n be put|
|00006100| 20 69 6e 74 6f 20 61 20 | 53 6f 75 6e 64 48 65 61 | into a |SoundHea|
|00006110| 64 65 72 20 64 61 74 61 | 20 73 74 72 75 63 74 75 |der data| structu|
|00006120| 72 65 2c 20 77 68 69 63 | 68 20 77 69 6c 6c 20 62 |re, whic|h will b|
|00006130| 65 20 75 73 65 64 20 6c | 61 74 65 72 20 77 68 65 |e used l|ater whe|
|00006140| 6e 20 64 61 74 61 20 69 | 73 20 70 61 73 73 65 64 |n data i|s passed|
|00006150| 20 74 6f 20 74 68 65 20 | 53 6f 75 6e 64 20 4d 61 | to the |Sound Ma|
|00006160| 6e 61 67 65 72 20 66 6f | 72 20 70 6c 61 79 69 6e |nager fo|r playin|
|00006170| 67 2e 20 54 68 65 20 72 | 6f 75 74 69 6e 65 20 70 |g. The r|outine p|
|00006180| 72 6f 76 69 64 65 64 20 | 69 6e 20 4d 75 6c 74 69 |rovided |in Multi|
|00006190| 42 75 66 66 65 72 20 65 | 78 74 72 61 63 74 73 20 |Buffer e|xtracts |
|000061a0| 6f 6e 6c 79 20 74 68 65 | 20 73 6f 75 6e 64 20 64 |only the| sound d|
|000061b0| 61 74 61 20 70 61 72 61 | 6d 65 74 65 72 73 2c 20 |ata para|meters, |
|000061c0| 73 75 63 68 20 61 73 20 | 74 68 65 20 6c 65 6e 67 |such as |the leng|
|000061d0| 74 68 2c 20 73 61 6d 70 | 6c 65 20 72 61 74 65 2c |th, samp|le rate,|
|000061e0| 20 73 61 6d 70 6c 65 20 | 73 69 7a 65 2c 20 61 6e | sample |size, an|
|000061f0| 64 20 6e 75 6d 62 65 72 | 20 6f 66 20 63 68 61 6e |d number| of chan|
|00006200| 6e 65 6c 73 2e 20 4f 74 | 68 65 72 20 63 68 75 6e |nels. Ot|her chun|
|00006210| 6b 73 20 61 72 65 20 63 | 75 72 72 65 6e 74 6c 79 |ks are c|urrently|
|00006220| 20 69 67 6e 6f 72 65 64 | 2c 20 61 6c 74 68 6f 75 | ignored|, althou|
|00006230| 67 68 20 74 68 65 20 63 | 6f 64 65 20 69 73 20 74 |gh the c|ode is t|
|00006240| 68 65 72 65 20 74 6f 20 | 73 75 70 70 6f 72 74 20 |here to |support |
|00006250| 73 69 70 68 6f 6e 69 6e | 67 20 74 68 65 20 69 6e |siphonin|g the in|
|00006260| 66 6f 72 6d 61 74 69 6f | 6e 20 6f 75 74 20 6f 66 |formatio|n out of|
|00006270| 20 74 68 65 6d 2e 20 47 | 65 74 41 49 46 46 48 65 | them. G|etAIFFHe|
|00006280| 61 64 65 72 49 6e 66 6f | 20 6c 65 61 76 65 73 20 |aderInfo| leaves |
|00006290| 74 68 65 20 66 69 6c 65 | 20 6d 61 72 6b 20 61 74 |the file| mark at|
|000062a0| 20 74 68 65 20 62 65 67 | 69 6e 6e 69 6e 67 20 6f | the beg|inning o|
|000062b0| 66 20 74 68 65 20 73 6f | 75 6e 64 20 64 61 74 61 |f the so|und data|
|000062c0| 20 61 6e 64 20 72 65 74 | 75 72 6e 73 20 74 68 65 | and ret|urns the|
|000062d0| 20 6e 75 6d 62 65 72 20 | 6f 66 20 62 79 74 65 73 | number |of bytes|
|000062e0| 20 6f 66 20 73 6f 75 6e | 64 20 64 61 74 61 20 69 | of soun|d data i|
|000062f0| 6e 20 74 68 65 20 66 69 | 6c 65 2e 0d 4f 6e 65 20 |n the fi|le..One |
|00006300| 6c 69 6d 69 74 61 74 69 | 6f 6e 20 6f 66 20 74 68 |limitati|on of th|
|00006310| 65 20 63 75 72 72 65 6e | 74 20 69 6d 70 6c 65 6d |e curren|t implem|
|00006320| 65 6e 74 61 74 69 6f 6e | 20 6f 66 20 74 68 69 73 |entation| of this|
|00006330| 20 72 6f 75 74 69 6e 65 | 20 69 73 20 74 68 61 74 | routine| is that|
|00006340| 20 69 74 20 64 65 61 6c | 73 20 6f 6e 6c 79 20 77 | it deal|s only w|
|00006350| 69 74 68 20 38 2d 62 69 | 74 20 6d 6f 6e 6f 70 68 |ith 8-bi|t monoph|
|00006360| 6f 6e 69 63 20 73 6f 75 | 6e 64 73 2e 20 0d 4f 53 |onic sou|nds. .OS|
|00006370| 45 72 72 20 52 65 63 6f | 72 64 41 49 46 46 46 69 |Err Reco|rdAIFFFi|
|00006380| 6c 65 20 28 4f 53 54 79 | 70 65 20 63 72 65 61 74 |le (OSTy|pe creat|
|00006390| 6f 72 29 0d 46 6f 75 6e | 64 20 69 6e 09 41 49 46 |or).Foun|d in.AIF|
|000063a0| 46 47 6f 6f 64 69 65 73 | 2e 63 0d 52 65 63 6f 72 |FGoodies|.c.Recor|
|000063b0| 64 41 49 46 46 46 69 6c | 65 20 75 73 65 73 20 74 |dAIFFFil|e uses t|
|000063c0| 68 65 20 73 6f 75 6e 64 | 20 69 6e 70 75 74 20 72 |he sound| input r|
|000063d0| 6f 75 74 69 6e 65 20 53 | 6e 64 52 65 63 6f 72 64 |outine S|ndRecord|
|000063e0| 54 6f 46 69 6c 65 20 74 | 6f 20 72 65 63 6f 72 64 |ToFile t|o record|
|000063f0| 20 61 20 73 6f 75 6e 64 | 20 74 6f 20 61 6e 20 41 | a sound| to an A|
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.